lay服务会导致DexIndexOverflowExceptio

lay服务会导致DexIndexOverflowExceptio

本文介绍了导入Google Play服务会导致DexIndexOverflowException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图实现View.OnClickListener接口和GoogleApiclient,如下所示:

  public class MainActivity extends Activity implements 
View.OnClickListener,GoogleApiClient.ConnectionCallbacks,OnConnectionFailedListener,com.google.android.gms.location.LocationListener {
}

但是,这会失败,出现以下错误:

Gradle控制台错误
ote:

  H:\xxx\app\src\main\ java\com\dbprox\css\MainActivity.java使用或覆盖弃用的API。 
注意:使用-Xlint:deprecation重新编译以获取详细信息。

:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:preDexDebug UP-TO-DATE
:app:dexDebug
AGPBI:{kind:simple,text:意外的顶级例外:,sources:[{}]}
AGPBI:{kind:simple,text :com.android.dex.DexIndexOverflowException:方法ID不在[0,0xffff]:65536,sources:[{}]}
AGPBI:{kind:simple,text :\tat com.android.dx.merge.DexMerger $ 6.updateIndex(DexMerger.java:484),sources:[{}]}
AGPBI:{kind:simple ,text:\tat com.android.dx.merge.DexMerger $ IdMerger.mergeSorted(DexMerger.java:261),sources:[{}]}
AGPBI:{kind :simple,text:\tat com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:473),sources:[{}]}
AGPBI:{ kind:simple,text:\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:161),sources:[{}]}
AGPBI: {kind:simple,text:\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:188),sources:[{}]}
AGPBI:{ kind:simple,text:\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504),sources:[{}]}
AGPBI:{kind:simple,text:\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:334),sources:[{}]}
AGPBI:{kind:simple,text:\tat com.android.dx.command.dexer.Main.run(Main.java:277),sources:[ {}]}
AGPBI:{kind:simple,text:\tat com.android.dx.command.dexer.Main.main(Main.java:245),来源:[{}]}
AGPBI:{kind:simple,text:\tat com.android.dx.command.Main.main(Main.java:106) ,来源:[{}]}


失败

失败:构建失败,出现异常。




  • 出错:
    执行失败任务':app:dexDebug'。

    因此,如果您需要Google Drive,请将其替换为:

      compile'c​​om。 google.android.gms:play-services:9.2.0'

    有了这个:

      compile'c​​om.google.android.gms:play-services-drive:9.2.0'


    I am trying to implement View.OnClickListener interface with and GoogleApiclient as below

        public class MainActivity extends Activity implements
     View.OnClickListener,GoogleApiClient.ConnectionCallbacks,OnConnectionFailedListener, com.google.android.gms.location.LocationListener{
        }
    

    But this fails with below error

    Below is the Gradle Console Errorote:

     H:\xxx\app\src\main\java\com\dbprox\css\MainActivity.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    
    :app:compileDebugNdk UP-TO-DATE
    :app:compileDebugSources
    :app:preDexDebug UP-TO-DATE
    :app:dexDebug
    AGPBI: {"kind":"simple","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","sources":[{}]}
    AGPBI: {"kind":"simple","text":"com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536","sources":[{}]}
    AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:484)","sources":[{}]}
    AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:261)","sources":[{}]}
    AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:473)","sources":[{}]}
    AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:161)","sources":[{}]}
    AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:188)","sources":[{}]}
    AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)","sources":[{}]}
    AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)","sources":[{}]}
    AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.run(Main.java:277)","sources":[{}]}
    AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.main(Main.java:245)","sources":[{}]}
    AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.Main.main(Main.java:106)","sources":[{}]}
    
    
     FAILED
    
    FAILURE: Build failed with an exception.
    

    • What went wrong:Execution failed for task ':app:dexDebug'.

    • Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    BUILD FAILED

    解决方案

    Your project has exceeded 65536 methods due to the amount of libraries you are importing.

    You are in luck though, because Google Play Services now allows you to pick and choose sub-modules to import, instead of importing the entire thing.This allows you to quickly and easily fix this issue.

    From the documentation:

    So, if Google Drive is all you need, then replace this:

    compile 'com.google.android.gms:play-services:9.2.0'
    

    With this:

    compile 'com.google.android.gms:play-services-drive:9.2.0'
    

    这篇关于导入Google Play服务会导致DexIndexOverflowException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 08:10