“程序類型已存在”是什么意思?我正在嘗試在Android Studio中構(gòu)建應(yīng)用。將Eclipse Paho庫添加為gradle依賴項(或者是Maven?我是Android生態(tài)系統(tǒng)的新手)后,我收到以下錯誤:Program type already present: android.support.v4.accessibilityservice.AccessibilityServiceInfoCompatMessage{kind=ERROR, text=Program type already present: android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat, sources=[Unknown source file], tool name=Optional.of(D8)}我已經(jīng)檢查了許多與此錯誤相關(guān)的不同StackOverflow問題,但答案都是特定于某些庫的。 我不僅要尋找錯誤的解決方案,還要了解錯誤的含義。 這樣,人們就可以更容易地找出針對特定案例的解決方案。到目前為止,還沒有答案提供。從其他StackOverflow答案中,我發(fā)現(xiàn)它與我的gradle文件有關(guān)。所以,這是app / build.gradle:apply plugin: 'com.android.application'android {
compileSdkVersion 27
defaultConfig {
applicationId "---REDACTED FOR PRIVACY---"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}}dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:support-media-compat:27.1.0'
implementation 'com.android.support:support-v13:27.1.0'
implementation 'com.google.android.gms:play-services-maps:12.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2'
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.0.2'}repositories {
maven { url 'https://repo.eclipse.org/content/repositories/paho-releases/' }}
3 回答

ibeautiful
TA貢獻(xiàn)1993條經(jīng)驗 獲得超6個贊
來自官方文件
如果類在運行時類路徑上出現(xiàn)多次,則會出現(xiàn)類似于以下內(nèi)容的錯誤:
Program type already present com.example.MyClass
由于下列情況之一,通常會發(fā)生此錯誤:
二進(jìn)制依賴項包括您的應(yīng)用程序還包含的庫作為直接依賴項。
例如,您的應(yīng)用程序聲明對庫A和庫B的直接依賴,但庫A已在其二進(jìn)制文件中包含庫B. 要解決此問題,請刪除庫B作為直接依賴項。
您的應(yīng)用程序在同一個庫上具有本地二進(jìn)制依賴項和遠(yuǎn)程二進(jìn)制依賴項。
要解決此問題,請刪除其中一個二進(jìn)制依賴項。(看看是否添加了相同的庫作為jar和gradle依賴項)
- 3 回答
- 0 關(guān)注
- 689 瀏覽
添加回答
舉報
0/150
提交
取消