webView console Uncaught TypeError

android 4.2系统上,混淆后,webView 不能正常调用JS

LOG提示:

Web Console(28886):Uncaught TypeError: Object [object Object] has no Method

 

 

混淆后,找不到方法,我试试了很多都不行,最后加了两句,解决了,

-keepattributes *Annotation*

-keepclassmembers class * {

   @android.webkit.JavascriptInterface ;

}

 

 

 

 

 

下面的是RPOGUARD官网的android Application混淆的模板,

 

-injars     bin/classes

-injars     libs

-outjars    bin/classes-processed.jar

-libraryjars/usr/local/java/android-sdk/platforms/android-9/android.jar

 

-dontpreverify

-repackageclasses ''

-allowaccessmodification

-optimizations!code/simplification/arithmetic

-keepattributes *Annotation*

 

-keep public class * extendsandroid.app.Activity

-keep public class * extendsandroid.app.Application

-keep public class * extendsandroid.app.Service

-keep public class * extendsandroid.content.BroadcastReceiver

-keep public class * extendsandroid.content.ContentProvider

 

-keep public class * extendsandroid.view.View {

   public (android.content.Context);

   public (android.content.Context, android.util.AttributeSet);

   public (android.content.Context, android.util.AttributeSet,int);

   public void set*(...);

}

 

-keepclasseswithmembers class * {

   public (android.content.Context, android.util.AttributeSet);

}

 

-keepclasseswithmembers class * {

   public (android.content.Context, android.util.AttributeSet,int);

}

 

-keepclassmembers class * extendsandroid.content.Context {

  public void *(android.view.View);

  public void *(android.view.MenuItem);

}

 

-keepclassmembers class * implementsandroid.os.Parcelable {

   static ** CREATOR;

}

 

-keepclassmembers class **.R$* {

   public static ;

}

 

-keepclassmembers class * {

   @android.webkit.JavascriptInterface ;

}

 

 

 

这里的是我的APP参考模板

# To enable ProGuard in your project, editproject.properties

# to define the proguard.config property asdescribed in that file.

#

# Add project specific ProGuard rules here.

# By default, the flags in this file areappended to flags specified

# in ${sdk.dir}/tools/proguard/proguard-android.txt

# You can edit the include path and orderby changing the ProGuard

# include property in project.properties.

#

# For more details, see

#  http://developer.android.com/guide/developing/tools/proguard.html

 

# Add any project specific keep optionshere:

 

 

 

 

-optimizationpasses 5

-dontusemixedcaseclassnames

-dontskipnonpubliclibraryclasses

-dontpreverify

-verbose

-optimizations!code/simplification/arithmetic,!field/*,!class/merging/*

 

-keep public class * extends android.app.Activity

-keep public class * extendsandroid.app.Application

-keep public class * extendsandroid.app.Service

-keep public class * extendsandroid.content.BroadcastReceiver

-keep public class * extendsandroid.content.ContentProvider

-keep public class * extendsandroid.app.backup.BackupAgentHelper

-keep public class * extendsandroid.preference.Preference

-keep public classcom.android.vending.licensing.ILicensingService

-keep public class android.webkit.WebView

 

-keepclasseswithmembernames class * {

   native ;

}

 

-keepclasseswithmembers class * {

   public (android.content.Context, android.util.AttributeSet);

}

 

-keepclasseswithmembers class * {

   public (android.content.Context, android.util.AttributeSet,int);

}

 

-keepclassmembers class * extendsandroid.app.Activity {

  public void *(android.view.View);

}

 

-keepclassmembers enum * {

   public static **[] values();

   public static ** valueOf(java.lang.String);

}

 

-keep class * implementsandroid.os.Parcelable {

 public static final android.os.Parcelable$Creator *;

}

 

-keepclassmembers class * {

  public (org.json.JSONObject);

}

 

-keep public class [package].R$*{

         publicstatic final int *;

}

 

 

 

# If your project uses WebView with JS,uncomment the following

# and specify the fully qualified classname to the JavaScript interface

# class:

#-keepclassmembers classfqcn.of.javascript.interface.for.webview {

#  public *;

#}

 

 

 

#-keepclassmembers class[package].msg.JavaScriptCallBack {

#    *;

#}

 

 

-keep public class[package].msg.JavaScriptCallBack

 

 

-keepclassmembers class[package].msg.JavaScriptCallBack {

   ;

}

 

-keepclassmembers class * {

   @android.webkit.JavascriptInterface ;

}

 

 

 

 

 

 

 

-keepclassmembers class com.google.zxing.client.android.ViewfinderView{

   *;

}

 

 

-keep class com.umeng.** {

         *;

}

 

-keep class com.baidu.** {

         *;

}

 

 

 

你可能感兴趣的:(bug集合,我和Android)