Android 使用依赖于外部JAR的库项目设置Proguard
我的android项目有很多依赖项,其中一个有一个libs文件夹和一些jar,在我尝试使用proguard之前,一切都很正常 运行proguard时,我发现此日志出错:Android 使用依赖于外部JAR的库项目设置Proguard,android,proguard,showcaseview,Android,Proguard,Showcaseview,我的android项目有很多依赖项,其中一个有一个libs文件夹和一些jar,在我尝试使用proguard之前,一切都很正常 运行proguard时,我发现此日志出错: Warning: [!!few lines like this!!]: can't find superclass or interface [...] Warning: [!!many lines like this!!]: can't find referenced class [...] You should
Warning: [!!few lines like this!!]: can't find superclass or interface [...]
Warning: [!!many lines like this!!]: can't find referenced class [...]
You should check if you need to specify additional program jars.
Warning: there were 190 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
Warning: there were 6 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile them and try again.
Alternatively, you may have to specify the option
'-dontskipnonpubliclibraryclassmembers'.
java.io.IOException: Please correct the above warnings first.
然后,我尝试在proguard配置文件中添加-libraryjars标志,导致此附加警告,而不是其他警告:
Note: there were 698 duplicate class definitions.
我无法预测的库项目是ShowcaseView(com.espian.ShowcaseView)
其库的libs文件夹中的jar是:
- android-support-v4.jar
- mockito-all-1.9.5.jar
- Nineodeldroids-2.4.0.jar
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
#-libraryjars ../ShowcaseView-master/library/libs/android-support-v4.jar
#-libraryjars ../ShowcaseView-master/library/libs/mockito-all-1.9.5.jar
#-libraryjars ../ShowcaseView-master/library/libs/nineoldandroids-2.4.0.jar
-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
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** i(...);
public static *** w(...);
}
-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 *;
}
#this is a try for all assets and res/raw/*html!
-keepclassmembers class **.R$* {
public static <fields>;
}
-keep class **.R$*
#ACRA specifics
# Restore some Source file names and restore approximate line numbers in the stack traces,
# otherwise the stack traces are pretty useless
-keepattributes SourceFile,LineNumberTable
# ACRA needs "annotations" so add this...
# Note: This may already be defined in the default "proguard-android-optimize.txt"
# file in the SDK. If it is, then you don't need to duplicate it. See your
# "project.properties" file to get the path to the default "proguard-android-optimize.txt".
-keepattributes *Annotation*
# keep this class so that logging will show 'ACRA' and not a obfuscated name like 'a'.
# Note: if you are removing log messages elsewhere in this file then this isn't necessary
-keep class org.acra.ACRA {
*;
}
# keep this around for some enums that ACRA needs
-keep class org.acra.ReportingInteractionMode {
*;
}
-keepnames class org.acra.sender.HttpSender$** {
*;
}
-keepnames class org.acra.ReportField {
*;
}
# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter
{
public void addCustomData(java.lang.String,java.lang.String);
public void putCustomData(java.lang.String,java.lang.String);
public void removeCustomData(java.lang.String);
}
# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter
{
public void handleSilentException(java.lang.Throwable);
}
-优化过程5
-dontusemixedcaseclassnames
-DontskipnonPublicLibraryClass
-dontskipnonpubliclibraryclassmembers
-不要翻转
-冗长的
-优化!代码/简化/算术,!字段/*,!类/合并/*
#-libraryjars../ShowcaseView主机/library/libs/android-support-v4.jar
#-libraryjars../ShowcaseView主控/库/libs/mockito-all-1.9.5.jar
#-libraryjars../ShowcaseView主控/库/libs/nineodeldroids-2.4.0.jar
-keep public class*扩展android.app.Activity
-keep public class*扩展android.app.Application
-keep public class*扩展了android.app.Service
-keep public class*扩展了android.content.BroadcastReceiver
-keep public class*扩展了android.content.ContentProvider
-keep public class*扩展了android.app.backup.BackupAgentHelper
-keep public class*扩展了android.preference.preference
-保持公共类com.android.vending.licensing.ILicensingService
-assumenosideeffects类android.util.Log{
公共静态***d(…);
公共静态***v(…);
公共静态***i(…);
公共静态***w(…);
}
-KeepClassSwithMemberNames类*{
出生地的
}
-keepclassswithmembers类*{
public(android.content.Context、android.util.AttributeSet);
}
-keepclassswithmembers类*{
public(android.content.Context,android.util.AttributeSet,int);
}
-keepclassmembers类*扩展了android.app.Activity{
public void*(android.view.view);
}
-keepclassmembers枚举*{
公共静态**[]值();
公共静态**valueOf(java.lang.String);
}
-keep class*实现android.os.Parcelable{
公开静态最终android.os.Parcelable$Creator*;
}
#这是对所有资产和res/raw/*html的一次尝试!
-keepclassmembers类**.R$*{
公共静态;
}
-继续上课**$*
#ACRA细节
#还原某些源文件名并还原堆栈跟踪中的近似行号,
#否则堆栈跟踪就毫无用处了
-keepattributes源文件,LineNumberTable
#ACRA需要“注释”,所以添加此。。。
#注意:这可能已经在默认的“proguard android optimize.txt”中定义
#SDK中的文件。如果是,则不需要复制它。看你的
#“project.properties”文件以获取默认“proguard android optimize.txt”的路径。
-keepattributes*注释*
#保留该类,以便日志记录将显示“ACRA”,而不是像“a”这样的模糊名称。
#注意:如果要删除此文件中其他位置的日志消息,则不需要这样做
-保持类org.acra.acra{
*;
}
#为ACRA需要的一些枚举保留此项
-保持类org.acra.ReportingInteractionMode{
*;
}
-keepnames类org.acra.sender.HttpSender$**{
*;
}
-keepnames类org.acra.ReportField{
*;
}
#保留此文件,否则ProGuard会将其删除
-保持公共类org.acra.ErrorReporter
{
public void addCustomData(java.lang.String、java.lang.String);
公共数据(java.lang.String、java.lang.String);
public void removeCustomData(java.lang.String);
}
#保留此文件,否则ProGuard会将其删除
-保持公共类org.acra.ErrorReporter
{
public void handleSilentException(java.lang.Throwable);
}
试试这个
-libraryjars /libs/mail.jar
-libraryjars /libs/activation.jar
-libraryjars /libs/additionnal.jar
将jar文件路径写入progurd.cfg或proguard project.txt,您应该为库添加这些行。如果找不到参考类,它们将不会发出警告 -保持类com.nineolandroid.*{*;} -dontwarn-com.nineolandroids**
我添加了我在问题中编写的完整的proguard.cfgAs,我尝试添加-libraryjars,但唯一的结果是获得了一个新的警告:注意:有698个重复的类定义。所以,我认为这不是解决办法。