Nau*_*que 23 merge android gradle dex android-studio-3.0
我做了:
错误是:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Run Code Online (Sandbox Code Playgroud)
项目build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
App build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.asanquran.mnaum.quranasaanurdutarjuma"
minSdkVersion 15
targetSdkVersion 26
versionCode 3
versionName "1.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-ads:11.4.2'
compile 'com.github.barteksc:android-pdf-viewer:2.3.0'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.google.firebase:firebase-ads:11.4.2'
compile 'com.google.firebase:firebase-messaging:11.4.2'
compile 'com.google.firebase:firebase-storage:11.4.2'
apply plugin: 'com.google.gms.google-services'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
请帮助我现在该怎么办
请不要标记它重复我已经尝试了几乎所有的解决方案
Ilk*_*Cat 25
<project>/app/并打开build.gradle文件defaultConfig和dependencies部分android {
...
defaultConfig {
...
multiDexEnabled true // ADD THIS LINE
}
}
...
dependencies {
...
implementation 'com.android.support:multidex:1.0.3' // ADD THIS LINE
}
Run Code Online (Sandbox Code Playgroud)
Vat*_*tel 17
我知道更新已经太晚了.我的项目也有同样的问题.
可能的原因
解决方案
使用以下命令检查依赖关系树,并查看依赖关系是否存在任何不匹配.
./gradlew :app:dependencies
Run Code Online (Sandbox Code Playgroud)您可以从任何依赖项中排除特定模块,如下所示.
implementation('com.google.android.ads.consent:consent-library:1.0.4') {
transitive = true
exclude group: "com.android.support"
}
Run Code Online (Sandbox Code Playgroud)在上面的示例中,它将从同意库依赖项中排除com.android.support组.
您也可以删除特定模块.
compile ('junit:junit:4.12'){
exclude group: 'org.hamcrest', module:'hamcrest-core'
}
Run Code Online (Sandbox Code Playgroud)在上面的例子中,它将从org.hamcrest中排除hamcrest-core.
Phi*_*bim 10
我得到了同样的问题,增加sourceCompatibility和targetCompatibility对我的build.gradle帮助我:
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
Run Code Online (Sandbox Code Playgroud)