【发布时间】:2016-12-26 16:47:10
【问题描述】:
我正在为地图应用程序运行 android studio 模板代码。但是出现错误。我点击这个链接只是为了运行一个简单的地图应用程序。
https://developers.google.com/maps/documentation/android-api/utility/setup
以下是错误。
错误:任务 ':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
我的问题是为什么我会收到此错误,因为我按照上面官方 Google 链接提供的所有步骤操作。
这是我的应用程序 Gradle 代码。
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "app.com.example.android.mapsnew"
minSdkVersion 16
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 {
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 'com.android.support:appcompat-v7:24.0.0'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.google.android.gms:play-services-maps:9.4.0'
testCompile 'junit:junit:4.12'
}
这是此错误的图像。
亲切的问候, 缩略词。
【问题讨论】:
-
谢谢@KNeerajLal 其实我正在关注这个官方链接。 >>developers.google.com/maps/documentation/android-api/utility/... 那么为什么在我的情况下这会出错。它应该按照链接中的说明工作。您所指的答案是告诉做很多与 MultiDexing 相关的程序。希望你明白我的意思。
-
build.gradle中的一个或多个依赖项导致您的 apk 中的方法数量超出 65k 方法限制。您可用的选项是,删除导致此或 Multidex 的依赖项。 -
在你的情况下,我认为删除
compile 'com.google.android.gms:play-services:9.4.0'会起作用。 -
我已经尝试过了,删除了 'compile 'com.google.android.gms:play-services:9.4.0'' 。它没有用并导致更多错误。我想说的是,除了来自谷歌的 ApiKey 之外,我没有在代码中添加任何内容。这应该可以正常工作,因为我正在学习教程:link
标签: android android-studio google-maps-api-3