Android代码混淆(第三方jar的混淆)
2013-12-02 14:43
405 查看
这是在工程中的proguard-project.txt中发现的
# 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 *;
#}
从脚本中可以看到,混淆中保留了继承自Activity、Service、Application、BroadcastReceiver、ContentProvider等基本组件以及com.android.vending.licensing.ILicensingService,
并保留了所有的Native变量名及类名,所有类中部分以设定了固定参数格式的构造函数,枚举等等。(详细信息请参考<proguard_path>/examples中的例子及注释。)
让proguard.cfg起作用的做法很简单,就是在eclipse自动生成的default.properties文件中加上一句“proguard.config=proguard.cfg”就可以了
完整的default.properties文件应该如下:
# This file is automatically generated
by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-15
proguard.config=proguard.cfg
Android代码混淆,如何过滤掉反射的R文件及第三方包?
解决方案:在Proguard.cfg方件中添加以下设定:
过滤R文件的混淆:
-keep class **.R$* { *; }
过滤第三方包的混淆:
-keep
class packagename.** {*;}(其中packagename为第三方包的包名)
Android导入第三方jar包,proguard混淆脚本(屏蔽警告,不混淆第三方包)
最近1个项目中
需要导入移动MM的第三方计费包,混淆时用
4000
到了如下脚本,可屏蔽警告,不混淆第三方包指定内容。
非常有效
proguard.cfg 文件
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-ignorewarnings //这1句是屏蔽警告,脚本中把这行注释去掉
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
//这1句是导入第三方的类库,防止混淆时候读取包内容出错,脚本中把这行注释去掉
-libraryjars libs/mmbilling.jar
-dontwarn //dontwarn去掉警告
-dontskipnonpubliclibraryclassmembers
-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>;
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
//这4句是不混淆第三方包中的指定内容,脚本中把这行注释去掉 -keep
class com.ccit.** {*; }
-keep class ccit.** { *; }
-keep class com.aspire.**
-keep class mm.vending.**
由www.J2meGame.com整理,转载请说明。
转载自 http://www.cnblogs.com/jason-star/archive/2012/09/07/2674906.html
# 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 *;
#}
从脚本中可以看到,混淆中保留了继承自Activity、Service、Application、BroadcastReceiver、ContentProvider等基本组件以及com.android.vending.licensing.ILicensingService,
并保留了所有的Native变量名及类名,所有类中部分以设定了固定参数格式的构造函数,枚举等等。(详细信息请参考<proguard_path>/examples中的例子及注释。)
让proguard.cfg起作用的做法很简单,就是在eclipse自动生成的default.properties文件中加上一句“proguard.config=proguard.cfg”就可以了
完整的default.properties文件应该如下:
# This file is automatically generated
by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-15
proguard.config=proguard.cfg
Android代码混淆,如何过滤掉反射的R文件及第三方包?
解决方案:在Proguard.cfg方件中添加以下设定:
过滤R文件的混淆:
-keep class **.R$* { *; }
过滤第三方包的混淆:
-keep
class packagename.** {*;}(其中packagename为第三方包的包名)
Android导入第三方jar包,proguard混淆脚本(屏蔽警告,不混淆第三方包)
最近1个项目中
需要导入移动MM的第三方计费包,混淆时用
4000
到了如下脚本,可屏蔽警告,不混淆第三方包指定内容。
非常有效
proguard.cfg 文件
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-ignorewarnings //这1句是屏蔽警告,脚本中把这行注释去掉
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
//这1句是导入第三方的类库,防止混淆时候读取包内容出错,脚本中把这行注释去掉
-libraryjars libs/mmbilling.jar
-dontwarn //dontwarn去掉警告
-dontskipnonpubliclibraryclassmembers
-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>;
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
//这4句是不混淆第三方包中的指定内容,脚本中把这行注释去掉 -keep
class com.ccit.** {*; }
-keep class ccit.** { *; }
-keep class com.aspire.**
-keep class mm.vending.**
由www.J2meGame.com整理,转载请说明。
转载自 http://www.cnblogs.com/jason-star/archive/2012/09/07/2674906.html
相关文章推荐
- Android笔记:防反编译、代码混淆中,解决第三方jar包不被混淆的一些心得,及gson防混淆方法 推荐
- Android 代码混淆及第三方jar包不被混淆
- Android代码混淆第三方jar,can't find referenced class的解决
- 解决android导入多个第三方jar包后项目代码混淆的问题
- Android 第三方Jar包FastJson 代码混淆时的解决方法
- Android 编程下引入第三方jar包进行代码混淆时的问题解决
- 关于android代码混淆 过滤第三方jar包
- 解决android导入多个第三方jar包后项目代码混淆的问题 .
- Android 代码混淆及第三方jar包不被混淆
- Android代码混淆第三方jar,can't find referenced class的解决
- Android代码混淆第三方jar,can't find referenced class的解决
- android 代码混淆 不混淆第三方jar包
- android 代码混淆 不混淆第三方jar包
- Android 第三方Jar包FastJson 代码混淆时的解决方法
- Android代码混淆常见配置
- Android代码混淆时出现的问题(Gson)
- android 代码混淆
- AndroidStudio开启代码混淆Progurad功能,防止你的app被反编译
- Android 高级混淆和代码保护技术
- android 代码混淆