有很多这样的问题,但似乎没有一个能解决我的问题,所以它可能更具体到错误消息中列出的库。我已经尝试了其他答案所建议的几乎所有内容,但仍然看到相同的错误。
我也遇到了运行任务错误,但我有multiDexEnabled true。
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
程序类型已经存在:android.support.v7.app.ActionBar$LayoutParams
Message{kind=ERROR, text=Program type already present: android.support.v7.app.ActionBar$LayoutParams, sources=[Unknown source file], tool name=Optional.of(D8)}
构建等级
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.my.app"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation project(':libs:DobSliding')
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.soundcloud.android:android-crop:1.0.1@aar'
implementation 'de.halfbit:pinned-section-listview:1.0.0'
implementation 'com.mikhaellopez:circularimageview:3.2.0'
implementation 'com.stripe:stripe-android:8.0.0'
implementation 'com.google.android.gms:play-services:12.0.1'
//noinspection GradleCompatible
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '26.1.0'
}
} else if (requested.group == "com.google.android.gms") {
details.useVersion '11.8.0'
} else if (requested.group == "com.google.firebase") {
details.useVersion '11.8.0'
}
}
}
实现项目(':libs:DobSliding')
我这里只有 1 个依赖项,所以我想知道这是否会导致冲突。
dependencies {
implementation 'com.nineoldandroids:library:2.4.0'
}
./gradlew app:dependencies
不太确定如何解释此输出:https://gist.github.com/WrightsCS/8888da5725357d62009773cee09997f0
最佳答案
原来我已经将一些 .jar 文件复制到 libs 文件夹中,而 Android Studio 正在使用它们并给了我错误。一旦我删除了有问题的库,例如 AppCompat.jar 和 classes.jar,构建就很好了。
检查任何 libs 文件夹以确保您没有携带任何可能已从 IntelliJ 项目 bundle 的 android 库。
关于Android 构建错误 : Program type already present: android. support.v7.app.**,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51902287/