【问题标题】:dex loader unable to execute dex: method ID not in [0, 0xffff]: 65536dex loader 无法执行 dex:方法 ID 不在 [0, 0xffff] 中:65536
【发布时间】:2014-11-13 17:20:07
【问题描述】:

我在构建我的应用程序时遇到了这个错误

Dx 警告:忽略匿名内部类的 InnerClasses 属性 (com.amazonaws.javax.xml.stream.xerces.util.SecuritySupport12$4) 不附带 关联的 EnclosureMethod 属性。这个类可能是由一个 不针对现代 .class 文件格式的编译器。推荐的 解决方案是使用最新的编译器从源代码重新编译类 并且没有指定任何“-target”类型选项。忽视的后果 此警告是此类上的反射操作将错误地 表明它不是一个内部类。

Dex Loader] 无法执行 dex:方法 ID 不在 [0, 0xffff] 中:65536 转换为 Dalvik 格式失败:无法执行 dex:方法 ID 不在 [0, 0xffff] 中:65536

【问题讨论】:

标签: android eclipse dalvik


【解决方案1】:

选中构建路径 -> Java 构建路径 -> 订购和导出选项卡 -> 取消选中 Android 私有库。

如果仍然无法正常工作,请将以下行添加到 project.properties 文件中:dex.force.jumbo=true

可能的原因是构建路径中的 jar 很大。

编辑: 这已被弃用,因为 Google 不再支持 Eclipse,如果您想摆脱这些烦人的问题:使用 Android Studio 并启用 Multidex。

【讨论】:

  • 取消选中私有库是我的解决方案
  • ^ 我不这么认为,取消选中会在运行时出现“未找到类 x”的错误..
  • 那么 Eclipse 太混乱了,以至于每次它都是一些奇怪的技巧让它工作。
  • 当然它不起作用,切换回库选项卡(订购和导出选项卡左侧),展开 Android 私有库并查看您的 APK 中缺少的内容。建议的第一部分(取消选中 Android Private Libraries)对于任何新的 Eclipse 用户来说都毫无用处和困惑。这不是 Eclipse 问题,而是 Android 设计问题和 Android 开发人员工具限制。 developer.android.com/tools/building/multidex.html
  • 对于那些仍然坚持使用 Eclipse 的人来说,这是完美的答案
【解决方案2】:

Driss Bounouar 解决方案实际上可以帮助您构建项目,但是您的应用程序在实施后可能会在某些地方崩溃,我认为它实际上在编译时抑制了问题。

我在控制台遇到的错误是:-

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.

根据这个 Trace,我尝试使用相同和最新的编译器重新编译所有项目,但仍然没有成功。

后来用旧的替换最新的 google Play services解决了我的问题。

我在几个小时前更新了我的 google play 服务,之后开始出现此错误。

编辑

要了解实际问题,您应该查看Building Apps with Over 65K Methods 在我们的情况下,旧的 google Play 服务似乎方法数量较少,因此项目编译成功。

简介

我们的整个项目被编译成一个 dex 文件,它有 65K 个方法的限制。但是现在您可以在项目中启用 multidex 文件。 目前可用的解决方案仅适用于 GRADLE (Android Studio),我还没有找到任何方法让它在 Eclipse 上运行。

【讨论】:

  • 这个为我的一位同事解决了这个问题,他已经更新了服务并且项目停止工作并出现描述的错误
  • 它并不总是一个损坏的类,有时它是项目库的大小,但你所说的对于真正解决问题是有效的 + 1 为你.. 他要求解决方案,所以我给出了第一个解决方案。
【解决方案3】:

遇到同样的问题。 google-play-services_lib 项目中存在问题。 它包括许多功能。此问题已在 21 和更新版本的 google-play-services_lib。

要解决多 dex 问题,您应该完全删除旧的 lib 项目并使用 google-play-services_lib_v_21 或更新版本。

例如,我使用了这个:google-play-services

附:还要记住官方google play setup docs说:

您应该引用复制到开发工作区的库的副本 - 您不应直接从 Android SDK 目录引用该库。

【讨论】:

  • 嗨,我仍然在使用较新版本的播放服务时遇到这个问题。有什么我可以做的吗?
  • 非常感谢。我使用了你的 21 Lib,它解决了我的问题。非常感谢你,伙计。万岁:)
【解决方案4】:

我刚刚在使用 Google Play 服务时在 Eclipse 上找到了解决此问题的替代方法。 因为在 Eclipse 上似乎没有办法像在 Android Studio(和 Gradle)中那样使用 multidex,这似乎是现在在 Eclipse 上工作的唯一方法。

  1. 进入 google-play-service-lib 项目
  2. 进入库
  3. 解压 google-play-services.jar 文件
  4. 进入解压后的文件夹并删除所有不需要的文件夹(即,如果您需要 Analytics,则可以删除广告、游戏、地图、钱包、驱动器等)
  5. 再次压缩这样一个文件夹(现在只包含所需的库)连同 MANIFEST 文件夹
  6. 在您的项目中使用这样的新 jar。

【讨论】:

  • 它正在工作,但 mapfragment 对我不起作用@ugo 你能告诉我任何解决我的问题的方法
  • 谢谢!让我免于跳到 Android 工作室,这对我的项目来说是一项乏味的任务!
  • 太棒了....!!!! @Ugo Chirico .. 非常感谢男人...自从 3 天以来,我一直没有解决这个问题.. 最佳答案..
  • 很好的解决方案,谢谢
【解决方案5】:

我最近也将 google play 库更新到版本 29,我的应用程序达到了 2^16 的限制!我降级到了第 26 版,我知道它对我有用,而且确实有效。

现在用 Eclipse 开发似乎变得相当不稳定,所以跟踪所有安装的包的所有版本是非常明智的!

长期的解决方案是切换到 Android Studio。

【讨论】:

    【解决方案6】:

    您收到此错误主要是因为 dalvik 可执行文件存在限制,显然限制是 65536,即 2^16。

    您必须为您的 android 应用程序启用多 dex 配置。 要启用多 dex,请按以下步骤操作:

    1. 编辑主模块(应用程序)的 build.gradle 文件

       android {
        defaultConfig {
          ...
         multiDexEnabled  true
       }
      }
      
      dependencies {
          ...
        compile 'com.android.support:multidex:1.0.1'
      }
      
    2. 告诉您的应用程序类来处理这些更改。

      您可以编辑自定义应用程序类以启用多 dex 支持。

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

      public class MyApplication extends MultiDexApplication{
      
      }
      

      编辑您的 AndroidManifest.xml 文件以将您的更改应用到应用程序标签

      <?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>
      

    API 级别 14 及以下有限制。您的应用程序可能无法在 API 级别 14 下编译或运行。编译时您可能会遇到 OutOfMemory 异常。要解决此问题,请将以下内容添加到 build.gradle

    dexOptions {
        jumboMode true
        javaMaxHeapSize "4g"
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多