12

iam building my application i got this error

Dx warning: Ignoring InnerClasses attribute for an anonymous inner class (com.amazonaws.javax.xml.stream.xerces.util.SecuritySupport12$4) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class.

Dex Loader] Unable to execute dex: method ID not in [0, 0xffff]: 65536 Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536

user3230564
  • 131
  • 1
  • 1
  • 6
  • Possible duplicate of [Unable to execute dex: method ID not in \[0, 0xffff\]: 65536](http://stackoverflow.com/questions/15209831/unable-to-execute-dex-method-id-not-in-0-0xffff-65536) – bummi Mar 14 '16 at 08:32

6 Answers6

54

Check the build path -> Java Build Path -> Order and Export tab -> uncheck Android private Librairies.

If it is still not working, add the following line : dex.force.jumbo=true to the project.properties file.

The probable cause is maybe a big sized jar in build path.

Edit : This is deprecated because Eclipse is no longer supported by Google, if you wanna get rid of these annoying problems : use Android Studio and enable Multidex.

Driss Bounouar
  • 3,182
  • 2
  • 32
  • 49
  • 12
    Unchecking private libraries was the fix in my case – DeltaCap019 Nov 07 '14 at 16:24
  • 14
    ^ I don't think so, unchecking gives the error on runtime that 'class x not found'.. – Farhan Apr 24 '15 at 10:46
  • 2
    Well Eclipse is so messed up that everytime it's some weird trick that make it work. – Driss Bounouar Apr 24 '15 at 11:37
  • 2
    Of cours it won't work, switch back to Libraries tab (left of Order and Export tab), expand Android Private Libraries and have a look at what will be missing from your APK. The first part of the suggestion (unchecking Android Private Libraries) is pretty useless and confusing to any new Eclipse user. It's not an Eclipse problem, it's an Android design issue and Android Developer Tools limitation. https://developer.android.com/tools/building/multidex.html – Dan Dar3 Aug 24 '15 at 00:16
  • 1
    For those who are still stuck with Eclipse, this is perfect answer – LoveForDroid Feb 24 '16 at 17:06
  • 1
    java.lang.NoClassDefFoundError – Iman Marashi Mar 26 '16 at 19:46
  • It worked ,,my question is wht are we uncheking it dont we need android private libraries in build ? – Utsav Gupta Aug 02 '16 at 13:10
  • It did not work..compiled all right but broke crashed on launch – Utsav Gupta Aug 02 '16 at 13:16
12

Driss Bounouar solution actually help you in building up your project, but your application may crash at some places after implementing it, I think it actually suppresses the issue at compile time.

The errors I was getting at console were :-

Dex Loader] Unable to execute dex: method ID not in [0, 0xffff]: 65536
Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536

[2014-11-08 15:51:58 - MLBPA] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class
(jnamed$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
[2014-11-08 15:51:58 - MLBPA] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class
(jnamed$2) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
[2014-11-08 15:51:58 - MLBPA] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class
(jnamed$3) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
[2014-11-08 15:51:59 - MLBPA] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.xbill.DNS.UDPClient$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.

According to this Trace I had tried recompiling my all the projects with same and latest compiler but still I was not getting any success.

Later on replacing latest google Play services with the older one fixed my issue.

I had updated my google play services few hours before and started getting this error there after.

EDIT

To understand the actual problem you should look at Building Apps with Over 65K Methods In our situation it looks like old google Play services had lesser number of methods and hence the project was successfully compiling.

Brief

Our whole project is compiled into one dex file which has limit of 65K methods. But now you can enable multidex files in you project. The solution available so far will work only with GRADLE (Android Studio), I haven't found any way to make it work on Eclipse.

DeltaCap019
  • 6,532
  • 3
  • 48
  • 70
  • 1
    this one solved it for a colleague of mine, he had updated the services and the project stopped working with the error described – Marc Nov 13 '14 at 12:37
  • 1
    It's not always a corrupt class sometimes it's the project libs size but what you said is valid to solve the issue genuinely + 1 for you.. he asked for solution so i give the first solution in mind. – Driss Bounouar Nov 14 '14 at 10:04
9

I just found an alternative to solve this issue on Eclipse when using Google Play Services. Because on Eclipse it seems that there is no way to use multidex as in Android Studio (and Gradle) this seems the only way to work on Eclipse rigth now.

  1. go in the google-play-service-lib project
  2. go in libs
  3. unzip the file google-play-services.jar
  4. go in the the unzipped folder and remove all folders that you don't need (i.e. if you need Analytics, you can remove ads, games, maps, wallet, drive, etc.)
  5. zip again such a folder (that now contains only the needed libraries) together with the MANIFEST folder
  6. use such new jar with your project.
Ugo Chirico
  • 347
  • 3
  • 6
4

Expirienced same issue. Problem was in google-play-services_lib project. It includes to many functions. This issue is fixed in 21 and newer versions of google-play-services_lib.

To fix multi-dex problem you should remove old lib project completely and use google-play-services_lib_v_21 or newer instead.

For example i used this one: google-play-services.

P.S. Also keep in mind that official google play setup docs say:

You should be referencing a copy of the library that you copied to your development workspace — you should NOT reference the library directly from the Android SDK directory.

Vitaliy A
  • 3,651
  • 1
  • 32
  • 34
0

I also had recently update the google play libs to version 29 and my app hit the 2^16 limit! I downgraded to version 26 that I knew it worked for me and indeed it has.

Developing with Eclipse seems to have become rather unstable now, so it is very advisable to keep track of all the versions of all packages installed!

The solution in the long term is to switch to Android Studio.

Edo user1419293
  • 171
  • 2
  • 9
0

You get this error mainly because there is a limitation on dalvik executable files and apparently the limit is 65536 which is 2^16.

You have to enable multi-dex configuration for your android application. To enable multi-dex, follow these steps:

  1. Edit your build.gradle file of your main module (app)

     android {
      defaultConfig {
        ...
       multiDexEnabled  true
     }
    }
    
    dependencies {
        ...
      compile 'com.android.support:multidex:1.0.1'
    }
    
  2. Tell your application class to handle these changes.

    You can edit your custom application class to enable multi-dex support.

    public class MyApplication extends Application {
    
    @Override
    protected void attachBaseContext(Context base) {
       super.attachBaseContext(base);
       MultiDex.install(this);
     }
    }
    

    OR

    public class MyApplication extends MultiDexApplication{
    
    }
    

    OR

    Edit your AndroidManifest.xml file to apply your changes to the application tag

    <?xml version="1.0" encoding="utf-8"?>        
    <manifestxmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.multidex.myapplication">
       <application
         ...
         android:name="android.support.multidex.MultiDexApplication">
         ...
       </application>
    

There are limitation below API Level 14 and below. Your app may not compile or run below API level 14. While compiling you can get OutOfMemory exception. To resolve this, add the following to build.gradle

dexOptions {
    jumboMode true
    javaMaxHeapSize "4g"
}
Srinivas
  • 21
  • 6