【问题标题】:Unable to execute dex: method ID not in [0, 0xffff]: 65536 in Eclipse无法执行 dex:方法 ID 不在 [0, 0xffff] 中:Eclipse 中的 65536
【发布时间】:2015-07-23 11:57:17
【问题描述】:

我正在 Eclipse 上开发一个应用程序。其中我需要使用以下libraries

1) 应用压缩

2) 谷歌播放服务

3) LiveSDK

4) json.jar

当我尝试运行我的项目时,它给出了这个错误。

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

即使我已经从 Java Buid Path 中删除了库,但我仍然收到此错误。

我也使用了progaurd,但错误没有解决。这是我的 progarud 文件

project.properties

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-22
android.library.reference.1=./workspace2/google-play-services_lib
android.library.reference.2=./workspace2/LiveSdk
android.library.reference.3=./android/workspace2/appcompat_v7

proguard-project.txt

-优化通过 5 -dontusemixedcase类名 -dontskipnonpubliclibraryclasses -dontpreverify -详细 -优化 !code/simplification/arithmetic,!field/,!class/merging/

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}
-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}

帮帮我!!

【问题讨论】:

标签: java android dalvik dex


【解决方案1】:

您已超出 65k 方法的限制。 因此,您想要的是启用 multidex 或在您的应用程序 + 库中拥有少于 65k 的方法。

有一个 multidex 支持库,但 ant 或 eclipse 不支持。 https://plus.google.com/+AndroidDevelopers/posts/HQM7qeosJoF

您还可以加载单独的 Play 服务 API,因为您可能不需要全部 https://developers.google.com/android/guides/setup

但你仍然需要 AS 和 gradle。

显然你可以在 eclipse 中使用 gradle 但我从未尝试过

Is it possible to use the Gradle build system for Android with Eclipse?

我的建议是迁移到 Android Studio

【讨论】:

    【解决方案2】:

    您收到此错误是因为您超出了 65k 限制。
    检查https://developer.android.com/tools/building/multidex.html

    【讨论】:

    • 我知道这一点。但想要任何解决方案。
    • @SandeepSingh 为您的应用添加多索引支持。在该链接中,它显示了如何执行此操作。我在 Android Studio 中也做过同样的事情,而且效果很好。不确定在 Eclipse 上是否有所不同。
    猜你喜欢
    • 1970-01-01
    • 2013-02-19
    • 2014-11-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多