Java Android Studio DexIndexOverflowException:方法 ID 不在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38714651/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Studio DexIndexOverflowException: method ID not in
提问by Hassan Ouhadou
I use Android Studio to develop an application and I face this error which I have no idea how to solve.
我使用 Android Studio 开发了一个应用程序,但遇到了这个我不知道如何解决的错误。
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]
com.android.dex.DexIndexOverflowException: 方法 ID 不在 [0, 0xffff]
:app:lintVitalRelease
:app:prePackageMarkerForRelease
:app:transformClassesWithDexForRelease FAILED
Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
> 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
Information:BUILD FAILED
Information:Total time: 34.783 secs
Information:1 error
回答by MrVietnamese
Try to enable multiDex in build.gradle:
尝试在 build.gradle 中启用 multiDex:
android {
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
This article may helpful: DexIndexOverflowException issue after updating to latest appcompat and support library
这篇文章可能有帮助:DexIndexOverflowException issue after updates to latest appcompat and support library
回答by vbp
Android has a pre-defined upper limit of Methods of 65536.
Android 有一个预定义的方法上限 65536。
if you added play services as whole please remove it and add specific ones.
如果您添加了整个播放服务,请删除它并添加特定的服务。
remove compile 'com.google.android.gms:play-services:9.6.1'
and then add ex: compile 'com.google.android.gms:play-services-maps:9.6.1'
for maps.
删除compile 'com.google.android.gms:play-services:9.6.1'
然后添加 ex:compile 'com.google.android.gms:play-services-maps:9.6.1'
用于地图。
https://developers.google.com/android/guides/setup
https://developers.google.com/android/guides/setup
shows a list of the separate APIs that you can include when compiling your app, and how to describe them in your build.gradle file
显示编译应用程序时可以包含的单独 API 的列表,以及如何在 build.gradle 文件中描述它们
回答by yaszin
more than 4 months that i find this error in my projects created by myself i'm losing more than 14 projects with this thing. i'm looking to all places of stackoverflow and other and also the website official of android.developer.multidex extr..... but any method official of google android was solve my issues.
四个多月以来,我在我自己创建的项目中发现了这个错误,我用这个东西丢失了超过 14 个项目。我正在寻找 stackoverflow 和其他的所有地方以及 android.developer.multidex extr 的网站官方......但是谷歌 android 的任何官方方法都解决了我的问题。
finally i'm trying with the simple change of google play service of Ads. this's the final solution that i'm finding :
最后,我正在尝试对 Ads 的 google play 服务进行简单的更改。这是我找到的最终解决方案:
firstly compile witch i find the error is : compile 'com.google.android.gms:play-services:9.0.2'
the change is just to add "-maps" and make sure that your ads it's working perfectly ! compile 'com.google.android.gms:play-services-maps:9.0.2'
首先编译女巫我发现错误是:编译'com.google.android.gms:play-services:9.0.2'
更改只是添加“-maps”并确保您的广告完美运行!编译 'com.google.android.gms:play-services-maps:9.0.2'
the version 9.0.2 can let your minSdkVersion 11 working, as you know the Ads can working only with version 11 and hight !
9.0.2 版本可以让您的 minSdkVersion 11 工作,正如您所知,广告只能与版本 11 和 hight 一起工作!
i'm proud to find the solution and share this simple solution to solve the issue of other persons.
我很自豪能找到解决方案并分享这个简单的解决方案来解决其他人的问题。
回答by scai
DexIndexOverflowException
is also caused by exceeding 65536 methods. This can easily happen when adding a large library such as Google Play services. See this answerfor a solution.
DexIndexOverflowException
也是超过65536个方法造成的。添加大型库(例如 Google Play 服务)时很容易发生这种情况。请参阅此答案以获取解决方案。
回答by Eugene Lezov
set multiDex in your gradle
在你的 gradle 中设置 multiDex
defaultConfig {
// ...
multiDexEnabled true
}
it's work for me.
这对我有用。
回答by Ahmad Aghazadeh
Best way use individual package under the list of all google services package.
最好的方法是使用所有谷歌服务包列表下的单个包。
Google Play services API Description in build.gradle
Google+ com.google.android.gms:play-services-plus:11.2.0
Google Account Login com.google.android.gms:play-services-auth:11.2.0
Google Actions, Base Client Librarycom.google.android.gms:play-services-base:11.2.0
Google Address API com.google.android.gms:play-services-identity:11.2.0
Google Analytics com.google.android.gms:play-services-analytics:11.2.0
Google Awareness com.google.android.gms:play-services-awareness:11.2.0
Google Cast com.google.android.gms:play-services-cast:11.2.0
Google Cloud Messaging com.google.android.gms:play-services-gcm:11.2.0
Google Drive com.google.android.gms:play-services-drive:11.2.0
Google Fit com.google.android.gms:play-services-fitness:11.2.0
Google Location and Activity Recognitioncom.google.android.gms:play-services-location:11.2.0
Google Mapscom.google.android.gms:play-services-maps:11.2.0
Google Mobile Ads com.google.android.gms:play-services-ads:11.2.0
Google Placescom.google.android.gms:play-services-places:11.2.0
Mobile Visioncom.google.android.gms:play-services-vision:11.2.0
Google Nearbycom.google.android.gms:play-services-nearby:11.2.0
Google Panorama Viewercom.google.android.gms:play-services-panorama:11.2.0
Google Play Game servicescom.google.android.gms:play-services-games:11.2.0
SafetyNetcom.google.android.gms:play-services-safetynet:11.2.0
Android Paycom.google.android.gms:play-services-wallet:11.2.0
Android Wearcom.google.android.gms:play-services-wearable:11.2.0
Google Play services API Description in build.gradle
Google+ com.google.android.gms:play-services-plus:11.2.0
Google Account Login com.google.android.gms:play-services-auth:11.2.0
Google Actions, Base Client Librarycom.google.android.gms:play-services-base:11.2.0
Google Address API com.google.android.gms:play-services-identity:11.2.0
Google Analytics com.google.android.gms:play-services-analytics:11.2.0
Google Awareness com.google.android.gms:play-services-awareness:11.2.0
Google Cast com.google.android.gms:play-services-cast:11.2.0
Google Cloud Messaging com.google.android.gms:play-services-gcm:11.2.0
Google Drive com.google.android.gms:play-services-drive:11.2.0
Google Fit com.google.android.gms:play-services-fitness:11.2.0
Google Location and Activity Recognitioncom.google.android.gms:play-services-location:11.2.0
Google Mapscom.google.android.gms:play-services-maps:11.2.0
Google Mobile Ads com.google.android.gms:play-services-ads:11.2.0
Google Placescom.google.android.gms:play-services-places:11.2.0
Mobile Visioncom.google.android.gms:play-services-vision:11.2.0
Google Nearbycom.google.android.gms:play-services-nearby:11.2.0
Google Panorama Viewercom.google.android.gms:play-services-panorama:11.2.0
Google Play Game servicescom.google.android.gms:play-services-games:11.2.0
SafetyNetcom.google.android.gms:play-services-safetynet:11.2.0
Android Paycom.google.android.gms:play-services-wallet:11.2.0
Android Wearcom.google.android.gms:play-services-wearable:11.2.0
回答by Kishore Reddy
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
solution : inside build.gradle(app)
defaultConfig {
applicationId "com.rentalhousereviews"
------------
-----------
multiDexEnabled true //add this line
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
回答by Tr?n H?nh
Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
任务 ':app:transformDexArchiveWithDexMergerForDebug' 执行失败。
com.android.build.api.transform.TransformException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
com.android.build.api.transform.TransformException: com.android.dex.DexIndexOverflowException: 方法 ID 不在 [0, 0xffff]: 65536
Latest version com.android.support:multidex:1.0.3
worked for me!
最新版本com.android.support:multidex:1.0.3
对我有用!
dependencies {
compile 'com.android.support:multidex:1.0.3'
}