无法在Eclipse中的[0,0xffff]:65536中执行dex:方法ID

时间:2015-07-23 11:57:17

标签: java android dalvik dex

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

1)AppCompact

2)Google Play服务

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     -dontusemixedcaseclassnames     -dontskipnonpubliclibraryclasses     -dontpreverify     -verbose     -optimizations!code / simplifiedification / arithmetic,!field / ,! class / merge /

-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;
}

帮助我!!

2 个答案:

答案 0 :(得分:2)

您已超过65k方法限制。 所以你想要的是启用multidex或你的app +库中的方法少于65k。

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

您还可以加载单个Play服务API,因为您可能并不需要它们 https://developers.google.com/android/guides/setup

但你仍然需要AS和gradle。

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

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

我的建议是迁移到Android Studio

答案 1 :(得分:0)

您因为超过65k的限制而收到此错误 查看https://developer.android.com/tools/building/multidex.html