accp_guoan
accp_guoan
采纳率0%
2016-06-16 08:38 阅读 1.7k

android 混淆报错 请看图片

20

To enable ProGuard in your project, edit project.properties

to define the proguard.config property as described in that file.

#

Add project specific ProGuard rules here.

By default, the flags in this file are appended to flags specified

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

You can edit the include path and order by 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 options here:

If your project uses WebView with JS, uncomment the following

and specify the fully qualified class name to the JavaScript interface

class:

#-keepclassmembers class fqcn.of.javascript.interface.for.webview {

public *;

#}

#代码混淆压缩比例
-optimizationpasses 5

#混淆时不使用大小写混合,混淆后的类名为小写
-dontusemixedcaseclassnames

#指定不去忽虑非公共的库的类
-dontskipnonpubliclibraryclasses

#指定不去忽虑非公共的库的类的成员
-dontskipnonpubliclibraryclassmembers

#不做预校验,preverify是proguard的四个步骤之一
#Android不需要preverify,去掉这一步可加快混淆速度
-dontpreverify

#有了verbose这句话,混淆后就会产生映射文件
#包含有类名 -> 混淆后类名的映射关系
-verbose
-printmapping priguardMapping.txt

#指定混淆时采用的算法,后面的参数是一个过滤器
#这个过滤器是谷歌推荐的算法,一般不改变
-optimizations !code/simplification/artithmetic,!field/*,!class/merging/*

#保护代码中的Annotation不被混淆
#这在JSON实体映射时非常重要,比如fastJson
-keepattributes Annotation

#避免混淆泛型
#这在JSON实体映射时非常重要,比如fastJson
-keepattributes Signature

#抛出异常时保留代码行号
-keepattributes Exceptions,InnerClasses,Signature,Deprecated, SourceFile,LineNumberTable,EnclosingMethod

#保留所有的本地native方法不被混淆
-keepclasseswithmembernames class * {
native ;
}

#保留了继承Activity,Application这些类的子类

比如第一行就保证了所有Activity的子类不要被混淆

-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 * extends android.view.View
-keep public class com.android.vending.licensing.ILicensingService

#保留Activity中的方法参数是view的方法
#从而是我在layout里面编写onClick就不会被影响
-keepclassmembers class * extends android.app.Activity{
public void *(android.view.View);
}

#枚举类不被混淆
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

保留自定义控件(继承自View)不能被混淆

-keep public class * extends android.view.View {
public (android.content.Context);
public (android.content.Context, android.util.AttributeSet);
public (android.content.Context, android.util.AttributeSet, int);
public void set*(***);
*** get* ();
}

保留Parcelable序列化的类不能被混淆

-keep class * implements android.os.Parcelable{
public static final android.os.Parcelable$Creator *;
}

保留Serializable 序列化的类不被混淆

-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
!static !transient ;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}

对R文件下的所有类及其方法,都不能被混淆

-keepclassmembers class **.R$* {
*;
}

对于带有回调函数onXXEvent的,不能混淆

-keepclassmembers class * {
void (*On*Event);
}

#实体类不参与混淆全部忽略
-keep class com.lefu.puhui.bases.newwork.reqmodel.** {*; }
-keep class com.lefu.puhui.bases.newwork.respmodel.** { ; }
-keep class com.lefu.puhui.bases.update.entity.Channel { *; }
-keep class com.lefu.puhui.bases.UserInfo {
;}
-keep class com.lefu.puhui.bases.GladlyStuLoan {*;}
-keep class com.lefu.puhui.bases.utils.CiphersUtil {*;}
-keep class com.lefu.puhui.bases.utils.SignMd5Util {*;}
-keep class com.lefu.puhui.bases.utils.MyToast {*;}
-keep class com.lefu.puhui.bases.utils.GenerateDeviceUniqueID {*;}
-keep class com.lefu.puhui.bases.utils.DataCleanManager {*;}
-keep class com.lefu.puhui.bases.utils.ViewHolder {*;}
-keep class com.lefu.puhui.models.home.network.reqmodel.** { ; }
-keep class com.lefu.puhui.models.home.network.respmodel.
* { ; }
-keep class com.lefu.puhui.models.main.network.reqmodel.
* { ; }
-keep class com.lefu.puhui.models.main.network.respmodel.
* { ; }
-keep class com.lefu.puhui.models.makemoney.network.reqmodel.
* { ; }
-keep class com.lefu.puhui.models.makemoney.network.respmodel.
* { ; }
-keep class com.lefu.puhui.models.more.network.reqmodel.
* { ; }
-keep class com.lefu.puhui.models.more.network.respmodel.
* { ; }
-keep class com.lefu.puhui.models.personalcenter.network.reqmodel.
* { ; }
-keep class com.lefu.puhui.models.personalcenter.network.respmodel.
* { *; }

#BaseFramework
-keep class com.bfec.BaseFramework.libraries.common.model.AccessResult {*;}
-keep class * extends com.bfec.BaseFramework.libraries.common.model.AccessResult {*;}
-keep class com.bfec.BaseFramework.libraries.common.model.RequestModel {*;}
-keep class * extends com.bfec.BaseFramework.libraries.common.model.RequestModel {*;}
-keep class com.bfec.BaseFramework.libraries.common.model.ResponseModel {*;}
-keep class * extends com.bfec.BaseFramework.libraries.common.model.ResponseModel {*;}

AMap_Location_V2.4.0

-libraryjars libs/AMap_Location_V2.4.0_20160308.jar
-keep class com.amap.** {*;}
-keep class com.autonavi.** {*;}
-keep class com.loc.** {*;}
-dontwarn com.amap.**
-dontwarn com.autonavi.**
-dontwarn com.loc.**

#android-support-v4
-libraryjars ../BaseFramework/libs/android-support-v4.jar
-keep class android.support.v4.** {*;}
-keep interface android.support.v4.** {*;}
-keep public class * extends android.support.v4.** {*;}
-dontwarn android.support.v4.**
-dontwarn android.support.annotaion.**

#bugly_crash_release__2.1.5
-libraryjars libs/bugly_crash_release__2.1.5.jar
-dontwarn com.tencent.bugly.**
-keep public class com.tencent.bugly.**{*;}

#butterknife
-libraryjars libs/ButterKnife_v7.0.1.jar
-keep class butterknife.** { ; }
-dontwarn butterknife.internal.
*
-keep class **$$ViewBinder { ; }
-keepclasseswithmembernames class * {
@butterknife.
;
}
-keepclasseswithmembernames class * {
@butterknife.* ;
}

#commons-codec-1.10
-libraryjars libs/commons-codec-1.10.jar
-keep class org.apache.** { *; }

#CommonUtil-1.0.8
-libraryjars libs/CommonUtil-1.0.8.jar
-keep class com.pay.** { ; }
-dontwarn com.pay.
*

#jpush-android-2.1.3
-libraryjars libs/jpush-android-2.1.3.jar
-dontoptimize
-dontwarn cn.jpush.**
-keep class cn.jpush.** { ; }
-dontwarn com.google.
*
-keep class com.google.gson.** {*;}
-dontwarn com.google.**
-keep class com.google.protobuf.** {*;}

#mta-sdk-1.6.2
-keep class com.tencent.** { *; }

#pinyin4j
-libraryjars libs/pinyin4j-2.5.0.jar
-dontwarn net.soureceforge.pinyin4j.**
-dontwarn demo.**
-keep class net.sourceforge.pinyin4j.** { ;}
-keep class demo.
* { *;}

#umeng
-libraryjars libs/umeng_social_sdk.jar
-dontwarn com.umeng.**
-keep class com.umeng*.** {*; }

#niversal-image-loader
-libraryjars libs/Universal_Image_Loader_v1.9.4.jar
-keep class com.nostra13.universalimageloader.** {*;}
-dontwarn com.nostra13.universalimageloader.**

#微博报下所有类及类里面的内容都不要混淆
-keep class com.sina.weibo.sdk.** { *; }

Gson

-libraryjars ../BaseFramework/libs/gson.jar
-keep class sun.misc.Unsafe {*;}
-keep class com.google.gson.** {*;}
-keep interface com.google.gson.** {*;}
-dontwarn com.google.gson.**

#httpmime
-libraryjars ../WelabSDK/libs/httpmime-4.1.1.jar
-keep class org.apache.http.** {*;}
-dontwarn org.apache.http.**

#LitePal
-libraryjars ../BaseFramework/libs/litepal.jar
-dontwarn org.litepal.*
-keep class org.litepal.** { ; }
-keep enum org.litepal.
*
-keep interface org.litepal.** { ; }
-keep public class * extends org.litepal.
*
-keepclassmembers class * extends org.litepal.crud.DataSupport{ *; }

#pulltorefresh
-libraryjars ../Library
-dontwarn com.handmark.pulltorefresh.library.**
-keep class com.handmark.pulltorefresh.library.** { ;}
-dontwarn com.handmark.pulltorefresh.library.extras.
*
-keep class com.handmark.pulltorefresh.library.extras.** { ;}
-dontwarn com.handmark.pulltorefresh.library.internal.
*
-keep class com.handmark.pulltorefresh.library.internal.** { *;}

#fastjson
-libraryjars ../WelabSDK/libs/fastjson-1.1.45.android.jar
-keep class com.alibaba.fastjson.** { ; }
-dontwarn com.alibaba.fastjson.
*

#org.apache.http.legacy
-libraryjars ../WelabSDK/libs/org.apache.http.legacy.jar
-keep class android.net.compatibility.** {*;}
-keep class android.net.http.** {*;}
-keep class com.android.internal.http.multipart.** {*;}
-keep class org.apache.** {*;}
-dontwarn android.net.**
-dontwarn org.apache.http.**

#PersonalSocialReportSDK
-libraryjars ../WelabSDK/libs/PersonalSocialReportSDK.jar
-dontwarn info.kuaicha.**

#jna-min
-libraryjars ../WelabFaceCheck/libs/jna-min.jar
-dontwarn com.sun.**

-keep class com.sun.jna.Native

-ignorewarnings

图片说明

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • qq_32341135 LRHuoLang19 2016-06-16 08:56

    cannot be cast to java.lang.string错误是类型转换错误,不是String类型的实例转成String的异常。

    点赞 评论 复制链接分享
  • boxing012 B0xing 2016-06-16 09:11

    先运行一下看看报错吗

    点赞 评论 复制链接分享

相关推荐