在我添加谷歌地图活动之前,我的应用程序正在正确编译。然后我得到这个错误
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-openjdk-amd64/bin/java'' finished with non-zero exit value 2
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
:app:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-openjdk-amd64/bin/java'' finished with non-zero exit value 2
build.gradle
android {
compileSdkVersion 24
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "zupportdesk.desk.zupport.chatsystem"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
compile 'org.java-websocket:Java-WebSocket:1.3.0'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'br.com.liveo:navigationdrawer-material:2.5.1'
compile files('libs/gson-2.2.2.jar')
compile files('libs/signalr-client-sdk-android.jar')
compile files('libs/signalr-client-sdk.jar')
}
有人能帮我解决这个问题吗?tnx
添加google地图后,方法和引用计数超过64K:
错误:.dex文件中的方法引用数不能超过64K.
这是一个大问题,每个大项目都会遇到这样的问题。但谷歌给出了一个解决方案:配置超过64K方法的应用程序。
根据你的问题
代替
compile 'com.google.android.gms:play-services:9.4.0'
使用这个
com.google.android.gms:play-services-maps:9.4.0
这将只包括地图所需的游戏服务。你的代码将导入所有的游戏服务包,这将导致你的应用程序跨越64K方法限制
将其添加到构建中。在buildTypes{…}:
dexOptions {
javaMaxHeapSize "4g"
}
将此依赖项添加到gradle…您的应用程序已达到64k参考限制。这里有更多
compile 'com.android.support:multidex:1.0.0'
还要加上
android {
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
}
根据Google的建议:选择性地将api编译到您的可执行文件中,您可以尝试在构建中替换以下行。gradle文件:
compile 'com.google.android.gms:play-services:9.6.1'
与你需要的:
compile 'com.google.android.gms:play-services-maps:9.6.1'
compile 'com.google.android.gms:play-services-xxx2:9.6.1'
compile 'com.google.android.gms:play-services-xxx3:9.6.1'