方法ID不在[0,0xffff]: 65536小应用错误



我们确实有一个小应用程序,不过,使用大约10jar。我被它缠住了。我配置了Proguard,它仍然显示同样的内容。根据Proguard的结果,我们只有500多个未使用的方法。我能做错什么或错过什么?

下面是gradle文件的依赖项:

Our "library"模块:

dependencies {
    compile 'com.android.support:support-v4:20.+'
    compile 'com.google.android.gms:play-services:+'
    compile files('libs/jackson-annotations-2.2.3.jar')
    compile files('libs/jackson-core-2.2.3.jar')
    compile files('libs/jackson-databind-2.2.3.jar')
    compile files('libs/okhttp-1.6.0.jar')
    compile files('libs/okhttp-urlconnection-1.6.0.jar')
    compile files('libs/okio-1.0.0.jar')
    compile files('libs/ormlite-android-4.48.jar')
    compile files('libs/ormlite-core-4.48.jar')
    compile files('libs/otto-1.3.4.jar')
    compile files('libs/picasso-2.3.2.jar')
    compile files('libs/retrofit-1.5.1.jar')
    compile project(':googlemapssdkm4b_lib')
}

app模块:

dependencies {
    compile project(':sherpaTaxiLibrary')
    compile project(':facebookSDK')
    compile project(':v4PrefFragment')
    compile 'com.android.support:appcompat-v7:20.+'
    compile 'com.android.support:support-v4:20.+'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.jakewharton:butterknife:5.1.1'
    compile 'com.braintreepayments.api:braintree:1.+'
    compile files('libs/twitter4j-core-4.0.2.jar')
}

下面是我的proguard代码:

##---------------Begin: proguard configuration common for all Android apps ----------
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose
-dump class_files.txt 
-printseeds seeds.txt 
-printusage unused.txt 
-printmapping mapping.txt 
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-allowaccessmodification
-keepattributes *Annotation*
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-repackageclasses ''
-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
-dontnote com.android.vending.licensing.ILicensingService
# Explicitly preserve all serialization members. The Serializable interface
# is only a marker interface, so it wouldn't save them.
-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}
# Preserve all native method names and the names of their classes.
-keepclasseswithmembernames class * {
    native <methods>;
}
-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}
# Preserve static fields of inner classes of R classes that might be accessed
# through introspection.
-keepclassmembers class **.R$* {
  public static <fields>;
}
# Preserve the special static methods that are required in all enumeration classes.
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}
-keep public class * {
    public protected *;
}
-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}
##---------------End: proguard configuration common for all Android apps ----------
##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# Gson specific classes
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.** { *; }
# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }
##---------------End: proguard configuration for Gson  ----------
-dontwarn rx.**, org.w3c.dom.**, com.squareup.okhttp.**, org.codehaus.mojo.**, 
java.nio.file.**, retrofit.** 
-libraryjars libs
-keep class com.google.gson.** { *; }
-keep class com.google.inject.* { *; }
-keep class org.apache.http.* { *; }
-keep class org.apache.james.mime4j.* { *; }
-keep class javax.inject.* { *; }
-keep class retrofit.* { *; }
-keep class com.example.testobfuscation.** { *; }
-keepattributes Signature
-keep class sun.misc.Unsafe { *; }

-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; } 
# Guava exclusions (http://code.google.com/p/guava-libraries/wiki/UsingProGuardWithGuava)
-dontwarn sun.misc.Unsafe
-dontwarn com.google.common.collect.MinMaxPriorityQueue
-keepclasseswithmembers public class * {
    public static void main(java.lang.String[]);
} 
# Guava depends on the annotation and inject packages for its annotations, keep them both
-keep public class javax.annotation.**
-keep public class javax.inject.**

ProGuard可能会为您删除许多类和方法,但是您的配置相当保守,显式地保留了许多类、字段和方法:

-keep class com.google.gson.** { *; }
-keep class com.google.inject.* { *; }
-keep class org.apache.http.* { *; }
.....

你可能在一个单独的文件中有更多的选项,例如Facebook SDK?

注意,文件proguard-project.txt基本上可以是空的,因为大部分配置已经在共享配置文件${sdk.dir}/tools/proguard/proguard-android.txt中指定(从project.properties引用)。使用正确的-keep选项创建更好的配置可能需要一些研究和实验。

你也不应该在配置文件中指定-injars-libraryjars选项。Gradle构建过程已经自动为您指定了所有必需的-injars-outjars-libraryjars

所以,我能够修复它。proguard代码实际上很好,但我把它放在错误的文件中。它应该在生成索引文件的模块中。我以前把它放在静态库中。

另外,我使用https://gist.github.com/dmarcato/d7c91b94214acd936e42删除了我不使用的Google Play Services包。我将代码放在生成APK的模块的gradle文件中。

谢谢。:)

相关内容

  • 没有找到相关文章

最新更新