我将项目更新为最新版本之后(Android Gradle插件版本为3.2.1,Gradle版本为4.6),包括支持最新的sdk版本(28)。我无法运行我的项目并抛出4个错误
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\0, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\1, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\2, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\3, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\4, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\5, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\6, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\7, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\8, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\9, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\10, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\11, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\12, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\13, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\14, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\15, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\16, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\17, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\18, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\19, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\20, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\21, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\22, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\23, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\24, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\25, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\26, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\27, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\28, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\29, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\30, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\31, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\32, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\33, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\34, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\35, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\36, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\37, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\38, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\39, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\40, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\41, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\42, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\43, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\44, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\45, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\46, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\47, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\48, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\49, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\50, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\51, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\52, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\53, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\54, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\55, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\56, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\57, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\58, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\59, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\60, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\61, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\62, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\63, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\64, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\65, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\66, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\67, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\68, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\69, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\70, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\71, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\72, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\73, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\74, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\75, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\76, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\77, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\78, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\79, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\80, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\81, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\82, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\83, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\84, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\85, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\86, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\87, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\88, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\89
和这个错误
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\0, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\1, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\2, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\3, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\4, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\5, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\6, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\7, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\8, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\9, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\10, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\11, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\12, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\13, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\14, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\15, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\16, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\17, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\18, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\19, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\20, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\21, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\22, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\23, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\24, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\25, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\26, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\27, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\28, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\29, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\30, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\31, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\32, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\33, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\34, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\35, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\36, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\37, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\38, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\39, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\40, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\41, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\42, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\43, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\44, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\45, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\46, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\47, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\48, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\49, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\50, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\51, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\52, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\53, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\54, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\55, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\56, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\57, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\58, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\59, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\60, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\61, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\62, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\63, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\64, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\65, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\66, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\67, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\68, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\69, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\70, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\71, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\72, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\73, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\74, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\75, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\76, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\77, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\78, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\79, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\80, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\81, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\82, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\83, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\84, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\85, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\86, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\87, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\88, G:\MoodyProjects\my-city-new\app\build\intermediates\transforms\dexBuilder\debug\89
和这个错误
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
和这个错误
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: com.google.gson.annotations.Expose
这是我的build.gradle(app)
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-perf'
//apply plugin: 'io.fabric'
/*Note see */
buildscript {
repositories {
//maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
dependencies {
//classpath 'io.fabric.tools:gradle:1.+'
}
}
/*
repositories {
//maven { url 'https://maven.fabric.io/public' }
}
*/
/*dor camera view libary*/
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '26.0.2'
}
}
}
}
}
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "co.my_city.new_android"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
/*Note: Android Studio disables ProGuard when using Instant Run.
If you need code shrinking for incremental builds, try the experimental Gradle shrinker.*/
/* Link : https://developer.android.com/studio/build/shrink-code.html#gradle-shrinker*/
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
release {
/*To enable code shrinking with ProGuard, add minifyEnabled true to the
appropriate build type in your build.gradle file*/
minifyEnabled false
/*To enable resource shrinking, set the shrinkResources property to true in
your build.gradle file (alongside minifyEnabled for code shrinking). For example:*/
//shrinkResources true ;
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.maps.android:android-maps-utils:0.5'
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-config:16.1.2'
implementation 'com.google.firebase:firebase-perf:16.2.3'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-invites:16.0.6'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
implementation 'net.gotev:uploadservice:3.1'
implementation 'com.github.charbgr:authmanager:1.0'
implementation 'com.mobsandgeeks:android-saripaar:2.0.3'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.github.Mariovc:ImagePicker:1.2.2'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'com.squareup.okhttp3:okhttp:3.10.0' // restful
implementation files('libs/gson-1.7.1.jar')
implementation 'com.afollestad.material-dialogs:core:0.9.6.0' // matrial dialogs ;
implementation 'com.karumi:dexter:4.2.0' // RTPersmisions
//compile 'org.jsoup:jsoup:1.11.2'
//compile 'com.karumi:dexter:4.2.0' // runtime permsions
implementation 'com.otaliastudios:cameraview:1.4.1'
//compile 'com.bignerdranch.android:expandablerecyclerview:1.0.3'
/*compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}*/
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
}
apply plugin: 'com.google.gms.google-services'
这是build.gradle(项目)
// Top-level build file where you can add configuration options common to
all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'com.google.firebase:firebase-plugins:1.1.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我不知道该如何解决此错误,如果其他人遇到相同的错误却找不到解决方案,我清理并重建了项目,但没有帮助。
答案 0 :(得分:0)
尝试将此行添加到build.gradle。
configurations {
all*.exclude group: 'com.google.code.gson'
}