这是我的app gradles文件,我在添加Google地图服务后无法尝试构建我的apk。该错误特别适用于编译com.google.android.gms:play-services-appindexing:9.8.0',其中声明混合版本可能导致运行时崩溃。
app gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.lunaemilia.fortius2"
minSdkVersion 11
targetSdkVersion 25
versionCode 1
versionName "1.0"
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:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0'
**compile 'com.google.android.gms:play-services-appindexing:9.8.0'**
compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.google.android.gms:play-services:10.0.1'
testCompile 'junit:junit:4.12'
}
我构建apk的错误是:
错误:任务':app:transformClassesWithDexForDebug'执行失败。
com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.dex.DexIndexOverflowException:方法ID不在[0, 0xffff]:65536
我该如何解决这个问题?
答案 0 :(得分:1)
请将以下行放入您的gradle构建的android defaultConfig
multiDexEnabled true
您需要启用Multidex