所以有人告诉我,使用 Android Studio 和最新版本的 Android SDK,我应该能够在我的项目上运行 Proguard,它使用 Android Annotations,没有任何问题。但是,我已经为此苦苦挣扎了很多天。
当我尝试通过 Android Studio 中的 Build->Generate Signed APK 工具运行 Proguard 时,我收到了数百个形式的错误:
com.googlecode.androidannotations.annotationprocessor.AnnotatedAbstractProcessor: can't find superclass or interface javax.annotation.processing.AbstractProcessor
com.googlecode.androidannotations.AndroidAnnotationProcessor: can't find referenced method 'void init(javax.annotation.processing.ProcessingEnvironment)' in class com.googlecode.androidannotations.annotationprocessor.AnnotatedAbstractProcessor
我已经尝试过使用 sdk 附带的内置 proguard-android.txt 文件以及我从 Android Annotations 复制的自定义文件,我相信:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !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>;
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
我也试过在命令行上通过 gradle 得到相同的结果。谁能帮我吗?