我该如何解决这个错误?方法 ID 不在 [0, 0xffff] 中:65536
How can i solve this error? Method ID not in [0, 0xffff]: 65536
我使用 MapsActivity 创建了一个新的 Android Studio 项目,如果我尝试在我的 Huawei P8 Lite 设备上启动该应用程序,则会出现此错误:
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.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
我的Build.Gradle(模块:应用程序):
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.de.maptestdel"
minSdkVersion 15
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.1.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.android.support:design:25.1.0'
testCompile 'junit:junit:4.12'
}
除了启用Multidex之外,还有其他方法可以解决吗?
听说激活不太好
使用来自 Google Play 服务库的 specific/individual API。您已使用 compile 'com.google.android.gms:play-services:10.0.1'
并且此库方法计数为 79958.
参考这个 link : https://developers.google.com/android/guides/setup
In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.
From version 6.5, you can instead selectively compile Google Play
service APIs into your app.
例如
对于 Google 地图,使用:
com.google.android.gms:play-services-maps:10.0.1
方法数:17984
对于 Google 云消息传递:
com.google.android.gms:play-services-gcm:10.0.1
方法数:15784
因此,使用单独的 API 将减少 apk 方法的数量。然后,无需启用 multidex。
我使用 MapsActivity 创建了一个新的 Android Studio 项目,如果我尝试在我的 Huawei P8 Lite 设备上启动该应用程序,则会出现此错误:
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.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
我的Build.Gradle(模块:应用程序):
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.de.maptestdel"
minSdkVersion 15
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.1.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.android.support:design:25.1.0'
testCompile 'junit:junit:4.12'
}
除了启用Multidex之外,还有其他方法可以解决吗? 听说激活不太好
使用来自 Google Play 服务库的 specific/individual API。您已使用 compile 'com.google.android.gms:play-services:10.0.1'
并且此库方法计数为 79958.
参考这个 link : https://developers.google.com/android/guides/setup
In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.
From version 6.5, you can instead selectively compile Google Play service APIs into your app.
例如
对于 Google 地图,使用:
com.google.android.gms:play-services-maps:10.0.1
方法数:17984
对于 Google 云消息传递:
com.google.android.gms:play-services-gcm:10.0.1
方法数:15784
因此,使用单独的 API 将减少 apk 方法的数量。然后,无需启用 multidex。