-injars androidtest.jar【jar包所在地址】 -outjars out【输出地址】 -libraryjars 'D:\android-sdk-windows\platforms\android-9\android.jar' 【引用的库的jar,用于解析injars所指定的jar类】
-optimizationpasses 5 -verbose -keep public class * extends android.app.Activity 【不进行混淆保持原样】 -keep public abstract interface com.asqw.android.Listener{ -keepclasseswithmembernames class * { 【保护指定的类和类的成员的名称,如果所有指定的类成员出席(在压缩步骤之后)】 native <methods>; -keepclasseswithmembers class * { 【保护指定的类和类的成员,但条件是所有指定的类和类成员是要存在。】 -keepclasseswithmembers class * { -keepclassmembers class * extends android.app.Activity {【保护指定类的成员,如果此类受到保护他们会保护的更好 】 -keepclassmembers enum * { -keep class * implements android.os.Parcelable {【保护指定的类文件和类的成员】 我在导出项目时报这种异常提示: 12-11-08 17:37:03 - com.zrwt.android.unicom.ui.LoginActivity] Proguard returned with error code 1. See console Warning: library class android.content.res.XmlResourceParser extends or implements program class org.xmlpull.v1.XmlPullParser Warning: library class android.content.Intent depends on program class org.xmlpull.v1.XmlPullParser Warning: library class android.content.IntentFilter depends on program class org.xmlpull.v1.XmlPullParser Warning: library class android.graphics.drawable.BitmapDrawable depends on program class org.xmlpull.v1.XmlPullParser Warning: library class android.graphics.drawable.Drawable depends on program class org.xmlpull.v1.XmlPullParser Warning: library class android.graphics.drawable.Drawable depends on program class org.xmlpull.v1.XmlPullParser Warning: library class android.graphics.drawable.Drawable depends on program class org.xmlpull.v1.XmlPullParser Warning: library class android.view.LayoutInflater depends on program class org.xmlpull.v1.XmlPullParser Warning: library class android.view.LayoutInflater depends on program class org.xmlpull.v1.XmlPullParser Warning: there were 9 instances of library classes depending on program classes. 找了半天才发现,我的工程中只有proguard-project.txt和project.properties文件,没有proguard.cfg,default.properties这两个文件, 并且我把proguard.config=proguard.cfg这句代码给加在了project.properties的文件中了。 所以才出现了如上错误。后来,我把那两文件给删了,从别的项目中考了default.properties和proguard.cfg的文件, 并把proguard.config=proguard.cfg这句话写在了default.properties文件中,混淆代码导出终于成功。大功告成! 加入第三方jar包之后常出现的几个异常: proguard returned with error code 1.See console
情况1: 在这里面有空格,而proguard进行发编译的时候是不允许有空格的 注意:SDK和程序路径最好不要有空格符 情况2: Proguard returned with error code 1. See console java.lang.ArrayIndexOutOfBoundsException 解决办法:将proguard.cfg中的"-dontpreverify"改成“-dontoptimize” 我把项目中生成的proguard文件夹(此时文件夹是空的)删掉,然后再重新运行项目,就OK 了。
情况3: [2011-10-21 13:22:32 - ZMKSMarket_Build_v1.0] Proguard returned with error code 1. See console [2011-10-21 13:22:32 - ZMKSMarket_Build_v1.0] java.io.IOException: Can't read [proguard.ClassPathEntry@106082] (No such file or directory) [2011-10-21 13:22:32 - ZMKSMarket_Build_v1.0] [2011-10-21 13:22:32 - ZMKSMarket_Build_v1.0] [2011-10-21 13:22:32 - ZMKSMarket_Build_v1.0] [2011-10-21 13:22:32 - ZMKSMarket_Build_v1.0] [2011-10-21 13:22:32 - ZMKSMarket_Build_v1.0] [2011-10-21 13:22:32 - ZMKSMarket_Build_v1.0] [2011-10-21 13:22:32 - ZMKSMarket_Build_v1.0]
抛出这样的异常的原因是第三方jar的引用路径不对,没有找到这个需要忽略混淆的jar包。 |