Android studio 无法仅在重建时合并 dex
Android studio Unable to merge dex only on rebuild
我有一个 android 使用 android studio 2.3 创建的项目。
现在我已经升级到 android studio 3 并且出现以下错误。
当我 运行 我的应用程序时,它会正常编译并安装在我的设备中。它工作正常。我对代码所做的任何更改都在设备中可见。
但是当我尝试重建时出现以下错误:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
这仅在重建时发生。我已经尝试清理和重建,而且我已经使 cache/Restart.
无效
有什么问题?
编辑:
我的应用 gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "gr.myapp1"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(':CoreServices-3.14.5')
compile project(':maflogoncore-1.214.5')
//compile project(':maflogonui-1.214.5')
compile project(':mafsettingscreen-1.214.5')
compile project(':mafuicomponents-1.214.5')
compile project(':MobilePlace-3.14.5')
compile project(':ODataOnline-3.14.5')
compile project(':Request-3.14.5')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:support-vector-drawable:25.3.1'
compile 'com.google.android.gms:play-services:11.0.2'
compile 'com.google.maps.android:android-maps-utils:0.4'
compile 'com.android.support:cardview-v7:25.3.1'
testCompile 'junit:junit:4.12'
}
//firebase
apply plugin: 'com.google.gms.google-services'
我的项目gradle文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
//firebase
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
最终我不得不启用 multidex 尽管我有 minimumVersion: 21
可能是因为我在创建项目时将其设置为 19,然后将其更改为 21。
我还没有找到为什么它在没有 multidex 的情况下一直工作,现在我升级到 Android studio 3 它需要它。
我有一个 android 使用 android studio 2.3 创建的项目。 现在我已经升级到 android studio 3 并且出现以下错误。
当我 运行 我的应用程序时,它会正常编译并安装在我的设备中。它工作正常。我对代码所做的任何更改都在设备中可见。
但是当我尝试重建时出现以下错误:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
这仅在重建时发生。我已经尝试清理和重建,而且我已经使 cache/Restart.
无效有什么问题?
编辑: 我的应用 gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "gr.myapp1"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(':CoreServices-3.14.5')
compile project(':maflogoncore-1.214.5')
//compile project(':maflogonui-1.214.5')
compile project(':mafsettingscreen-1.214.5')
compile project(':mafuicomponents-1.214.5')
compile project(':MobilePlace-3.14.5')
compile project(':ODataOnline-3.14.5')
compile project(':Request-3.14.5')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:support-vector-drawable:25.3.1'
compile 'com.google.android.gms:play-services:11.0.2'
compile 'com.google.maps.android:android-maps-utils:0.4'
compile 'com.android.support:cardview-v7:25.3.1'
testCompile 'junit:junit:4.12'
}
//firebase
apply plugin: 'com.google.gms.google-services'
我的项目gradle文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
//firebase
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
最终我不得不启用 multidex 尽管我有 minimumVersion: 21
可能是因为我在创建项目时将其设置为 19,然后将其更改为 21。
我还没有找到为什么它在没有 multidex 的情况下一直工作,现在我升级到 Android studio 3 它需要它。