0
votes

I'm a newbie for android and java. I want to move my existing project from eclipse to android studio and after I manage some dependencies I got this error below.

 Error:Execution failed for task ':mainActivity:dexDebug'.

com.android.ide.common.internal.LoggedErrorException: Failed to run command: /Users/nuttapol/android_sdk/build-tools/21.1.2/dx --dex --no-optimize --multi-dex --main-dex-list /Users/nuttapol/Documents/MyApp/New_App/MyApp_android/mainActivity/build/intermediates/multi-dex/debug/maindexlist.txt --output /Users/nuttapol/Documents/MyApp/New_App/MyApp_android/mainActivity/build/intermediates/dex/debug --input-list=/Users/nuttapol/Documents/MyApp/New_App/MyApp_android/mainActivity/build/intermediates/tmp/dex/debug/inputList.txt Error Code: 3 Output: objc[9912]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined. UNEXPECTED TOP-LEVEL ERROR: java.lang.OutOfMemoryError: Java heap space at java.util.zip.InflaterInputStream.(InflaterInputStream.java:88) at java.util.zip.ZipFile$ZipFileInflaterInputStream.(ZipFile.java:394) at java.util.zip.ZipFile.getInputStream(ZipFile.java:375) at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:269) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) at com.android.dx.command.dexer.Main.processOne(Main.java:632) at com.android.dx.command.dexer.Main.processAllFiles(Main.java:505) at com.android.dx.command.dexer.Main.runMultiDex(Main.java:334) at com.android.dx.command.dexer.Main.run(Main.java:244) at com.android.dx.command.dexer.Main.main(Main.java:215) at com.android.dx.command.Main.main(Main.java:106)

How can I resolve this error ?

3
I think your project is getting two Class JavaLaunchHelper references.Sanjay Hirani

3 Answers

0
votes

I faced the same answer and this was cleared by doing the following things.

1.Make sure Your Build.Gradle file has generated successfully

2.Clean the project and then restart the Android studio

but if the error still persist then the long but 100 % confirm working solution is :

  1. Make project with same namespace etc , and copy all of your files in the places such as java , xmls, string.xml etc.
0
votes

After check this answer :

Android Studio: Gradle - build fails -- Execution failed for task ':dexDebug'

Some libraries or external dependences, that was in a single jar file, I started to import them again as modules, in some cases it was ennough with create a new module and import the jar file, on others, simply it was necessary to include the dependence in a different way.

I hope this helps.

0
votes
UNEXPECTED TOP-LEVEL ERROR: java.lang.OutOfMemoryError: Java heap space at     java.util.zip.InflaterInputStream.(InflaterInputStream.java:88) at     java.util.zip.ZipFile$ZipFileInflaterInputStream.(ZipFile.java:394) at java.util.zip.ZipFile.getInputStream(ZipFile.java:375) 

This appears to be the actual offender. In your build.gradle add and adjust the following configuration:

android{
    dexOpts{
            javaMaxHeapSize "2g"
    }
}

The above example is for setting the max limit as 2GB. You should probably increase this incrementally and figure out where the sweet spot is for you and make your adjustments there.