4

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

Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_51\bin\java.exe'' finished with non-zero exit value 2

Below is the Gradle Console Error ote:

 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'.

    com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_51\bin\java.exe'' 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.

BUILD FAILED

Daniel Nugent
  • 43,104
  • 15
  • 109
  • 137
go sgenq
  • 313
  • 3
  • 13

2 Answers2

19

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:

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.

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' 
Daniel Nugent
  • 43,104
  • 15
  • 109
  • 137
0

I think some of your jar files does not compile. You should go into build.gradle file and look in your dependencies. If you're just importing some jar files, you may try to remove and add them one at a time. This will help you determine which one causes the error.

For the Error: MainActivity.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details., you are probably using an older version of the appcompat library. You may refer to this link.

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59
  • The problem is compile 'com.google.android.gms:play-services:8.3.0', removed it from the build.girdle. i am able to build the project. i need this library to connect to google drive.How can i add this library with any issue.compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile 'com.dropbox.core:dropbox-core-sdk:2.0-beta-5' compile 'com.google.code.gson:gson:2.3.1' compile 'com.microsoft.services.msa:msa-auth:0.8.4' compile 'com.microsoft.aad:adal:1.1.7' //compile 'com.google.android.gms:play-services:8.3.0' – go sgenq Feb 04 '16 at 16:25