我将 android studio 升级到了 3.0.1 版本。每当我尝试启动我的应用程序时,gradle 构建都会失败并出现以下错误:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
我尝试了堆栈溢出中提到的所有可能的解决方案,但没有任何帮助。
-每当我清理项目时都没有发生错误,但是当我重建项目时错误又回来了。
-我删除了.gradle文件和构建文件
-我从编译改成了实现
-我从 10.2.1 升级到 11.4.2 以获取 firebase 依赖项,但它给了我更多错误,例如 UNABLE TO RESOLVE DEPENDENCY
-我启用了 dex,但它又出现了更多错误。
-我启用了版本为 46 的 google play 服务
我搜索了所有可能的方法,但我无法解决这个问题。 请帮助我摆脱它,因为我所有的工作都被卡住了。 任何帮助表示赞赏!
build.gradle(项目)
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.0.0'
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(模块)
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "studentapp.notefi"
minSdkVersion 17
targetSdkVersion 24
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(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:24.1.1'
implementation 'com.android.support:design:24.1.1'
implementation 'com.android.support:support-v4:24.1.1'
implementation 'com.android.support:recyclerview-v7:24.1.1'
implementation 'com.android.support:cardview-v7:24.1.1'
implementation 'com.google.firebase:firebase-messaging:10.2.1'
implementation 'com.google.firebase:firebase-database:10.2.1'
implementation 'com.google.firebase:firebase-storage:10.2.1'
implementation 'com.google.firebase:firebase-auth:10.2.1'
implementation 'com.firebaseui:firebase-ui-database:0.4.0'
implementation 'com.github.barteksc:android-pdf-viewer:2.7.0'
implementation 'org.apache.commons:commons-io:1.3.2'
implementation 'com.google.firebase:firebase-crash:10.2.1'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.6'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.squareup.okhttp3:okhttp:3.2.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
最佳答案
请删除这一行:
task clean(type: Delete) {
delete rootProject.buildDir
}
休息,我检查了它的工作正常,我的意思是它成功构建。
已编辑:
使用此代码“com.google.android.gms:play-services:11.4.0”而不是“com.google.gms.google-services”。然后清理重建
关于java - android studio更新到3.0.1版本后报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47587285/