最佳答案
我想在安卓工作室里开发一个应用。在添加 Eclipse Paho 库作为渐变依赖项之后(或者它是 Maven?我是 Android 生态系统的新手) ,我得到了以下错误:
Program type already present: android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat
Message{kind=ERROR, text=Program type already present: android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat, sources=[Unknown source file], tool name=Optional.of(D8)}
我已经检查了许多与此错误相关的 StackOverflow 问题,但是答案都是特定于某些库的。这样人们就更容易找到针对特定情况的解决方案。到目前为止,还没有答案。
从 StackOverflow 的其他答案中,我总结出它与我的 gradle 文件有关,下面是 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/' }
}