0

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 ?

Pojimaru
  • 11
  • 1

3 Answers3

0

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.
Black
  • 21
  • 6
  • I've already do that before I make this post and It's not work. :( – Pojimaru Jan 09 '15 at 10:50
  • Did you try making new project and copy all the coding text into it ? – Black Jan 09 '15 at 11:02
  • what it says when you make your brand new project and run it as it is ? – Black Jan 12 '15 at 06:09
  • I got the same error. But I can build it now after updated my jdk. – Pojimaru Jan 12 '15 at 06:29
  • Oked First thing first 1. Upgrade your sdk specially use the latest build tools ihave same error and I removed not to install the latest build tool version such as 21.00 but I also installed 20,19,18,17 to 16 so I will also suggest you to do so 2.Chack in sdk that which Build tool version is installed in your sdk then go to build.gradle file and do the following changes ////////in build.gradle file defaultConfig { applicationId "your application package name" minSdkVersion 8 // change your build version here targetSdkVersion 20 versionCode 1 versionName "1.0" } – Black Jan 12 '15 at 07:36
0

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.

Community
  • 1
  • 1
ZLNK
  • 811
  • 14
  • 17
0
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.

ijunes
  • 582
  • 1
  • 4
  • 13