如何使用 proguard 混淆 android 应用程序。当为 apk 导出应用程序时,我遇到以下问题。
问题
[2013-09-26 13:16:53 - Fishing_log] Proguard returned with error code 1. See console
[2013-09-26 13:16:53 - Fishing_log] proguard.ParseException: Value of system property 'init' is undefined in 'string/app_name { <init>' in line 2 of file 'C:\Users\owner\workspace8\Fishing_log\bin\proguard.txt',
[2013-09-26 13:16:53 - Fishing_log] included from argument number 6
[2013-09-26 13:16:53 - Fishing_log] at proguard.ConfigurationParser.replaceSystemProperties(ConfigurationParser.java:1153)
[2013-09-26 13:16:53 - Fishing_log] at proguard.ConfigurationParser.file(ConfigurationParser.java:1113)
[2013-09-26 13:16:53 - Fishing_log] at proguard.ConfigurationParser.parseIncludeArgument(ConfigurationParser.java:242)
[2013-09-26 13:16:53 - Fishing_log] at proguard.ConfigurationParser.parse(ConfigurationParser.java:150)
[2013-09-26 13:16:53 - Fishing_log] at proguard.ProGuard.main(ProGuard.java:476)
我如何解决这个问题?
我在project.properties和proguard-project.txt中添加了以下代码
项目属性
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
proguard-project.txt
-injars lib
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-dontnote
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-dontwarn sun.misc.Unsafe, java.lang.management.ManagementFactory, org.codehaus.jackson.JsonParser, org.json.JSONObject, org.codehaus.jackson.JsonGenerator, org.codehaus.jackson.JsonFactory, com.google.common.collect.MinMaxPriorityQueue
-keep public class * extends android.app.Application
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-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 the R
-keepclassmembers class **.R$* {
public static <fields>;
}