2

启动后试图混淆我的phonegap应用程序我得到

367 D/CordovaLog(30913):file:///android_asset/www/cordova.js:第 913 行:未捕获的类型错误:对象 [对象对象] 没有方法“执行”

我想我尝试了网络中提到的所有选项,这是我的 proguard-project.txt

-keep public class * extends com.phonegap.api.Plugin 
-keep public class org.apache.cordova.** 
-keep class org.apache.cordova.** { *; }
-keep public class * extends org.apache.cordova.CordovaPlugin
-keep public class * extends org.apache.cordova.api.CordovaPlugin
-keep public class * extends com.phonegap.api.Plugin
-keep public class * extends org.apache.cordova.api.Plugin
-keep public class org.apache.cordova.DroidGap
-keep public class org.apache.cordova.**
-keep public class org.apache.**
-keep public class com.kazem.**
-keep public class nl.**
-dontwarn android.webkit.*
-dontwarn org.apache.**
-dontwarn  android.support.v7.widget.**
-dontwarn com.google.android.gms.**
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-keepdirectories
-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>;
}

-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 *;
}

-keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}
4

2 回答 2

1

我用了:

-keep public class * extends org.apache.cordova.CordovaPlugin
-keep public class * extends com.phonegap.api.Plugin 
-keep class org.apache.cordova.** { *; }
-dontwarn android.webkit.*
于 2014-10-14T18:01:55.493 回答
0

1).在project.properties文件中取消注释以下行

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

2).在AndroidSDk/tools/proguard/proguard-project.txt里面添加下面的代码,因为我们的项目使用的是带有JS的WebView所以,我们必须给JavaScript接口类指定全限定类名:

-keep public class * extends org.apache.cordova.CordovaPlugin
-keep public class * extends com.phonegap.api.Plugin 
-keep class org.apache.cordova.** { *; }
-dontwarn android.webkit.*

3).构建Android项目。4).将“proguard-project.txt”文件从“AndroidSDk/tools/proguard/proguard-project.txt”复制到android文件夹。
5).导出签名包:右键项目>android工具>导出签名应用包

于 2015-09-29T06:38:40.627 回答