proguard

Proguard function names ambiguity

非 Y 不嫁゛ 提交于 2019-12-01 12:58:19
问题 I need to know is there some option to prevent giving same name to different functions during obfuscation. Mapping file: org.apache.http.impl.client.cache.BasicHttpCacheStorage -> org.apache.http.impl.client.cache.f: 67:68:void putEntry(java.lang.String,org.apache.http.client.cache.HttpCacheEntry) -> a 78:78:org.apache.http.client.cache.HttpCacheEntry getEntry(java.lang.String) -> a I'd like to have different names for different functions instead of lines interval. Thanks 回答1: The option

annotations having no effect in proguard

…衆ロ難τιáo~ 提交于 2019-12-01 11:53:07
I'm having troubles getting proguard to keep things based on their annotations (under Android). I have an annotation, com.example.Keep: @Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR }) public @interface Keep { } I have a class, which is only ever constructed through reflection: public class Bar extends Foo { @com.example.Keep Bar(String a, String b) { super(a, b); } //... } It works as expected (class keeps its constructor albeit with an obfuscated class name) When my proguard config includes the following: -keepattributes Signature,*Annotation*

Obfuscate android.support.v7.widget.GridLayout issue

左心房为你撑大大i 提交于 2019-12-01 08:39:37
I'm trying to obfuscate my android application, where I use android.support.v7.appcompat and android.support.v7.GridLayout, but the app is crashing with the following exception: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.v7.widget.GridLayout at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698) at android.view.LayoutInflater.inflate(LayoutInflater.java:466) at android.view.LayoutInflater.inflate(LayoutInflater.java:396) at com.droid.fragments.c.al.onCreateView(Unknown Source) at android.support.v4.app.Fragment

Why some package-private classes are not obfuscated by Proguard?

拟墨画扇 提交于 2019-12-01 07:54:54
Working with an Android project in Android Studio 3.2, having enabled Proguard and some specific rules, I'm not able to figure out the following: a specific package (and its subpackages) in a library module, used by client code, is preserved through the rule: -keep public class com.mylib.mypackage.** { public protected *; } Now, within this package there are also a number of package-private classes, which should not be picked by that rule. Some of those classes are effectively obfuscated, both in their own names and their member names, which is fine. Instead there are some classes,

Android Studio 代码混淆

时光怂恿深爱的人放手 提交于 2019-12-01 06:45:35
在Android studio 进行代码混淆配置。 proguard 配置 -keepclasseswithmembers 指定的类和类成员被保留,假如指定的类成员存在的话。 -dontwarn 缺省proguard 会检查每一个引用是否正确,但是第三方库里面往往有些不会用到的类,没有正确引用。如果不配置的话,系统就会报错。 -keep 指定的类和类成员被保留作为 入口 。 -keepclassmembers 指定的类成员被保留。 proguard 问题和风险 代码混淆后虽然有混淆优化的好处,但是它往往也会带来如下的几点问题 混淆错误,用到第三方库的时候,必须告诉 proguard 不要检查,否则proguard 会报错。 运行错误,当code 不能混淆的时候,我们必须要正确配置,否则程序会运行出错,这种情况问题最多。 调试苦难,出错了,错误堆栈是混淆后的代码 ,自己也看不懂。 不能混淆的代码 下面这样代码混淆的时候要注意保留。 Android系统组件,系统组件有固定的方法被系统调用。 被Android Resource 文件引用到的。名字已经固定,也不能混淆,比如自定义的View Android Parcelable ,需要使用android 序列化的。 Java序列化方法,系统序列化需要固定的方法。 枚举 ,系统需要处理枚举的固定方法 本地方法,不能修改本地方法名

Jean同学的Proguard私房物语

醉酒当歌 提交于 2019-12-01 06:44:53
由于项目中自主研发的一个Android平台工具库需要提供给外部人员使用,我们决定使用android sdk自带的proguard tool混淆源码。在动用了google之后得到的大量资源文中,拨云见雾、去糟存精,融会贯通理论于实践,自我成长之余制作以下proguard源码混淆独家宝典。 无耻的分割线---------------------------------------------------------------------------------------------------------------------- 本文是以项目中进行混淆的步骤以及其间遇到的问题为主线,行文略乱,洁癖er轻拍。 1. proguard工具身藏Android sdk何处: android-sdks/tools/proguard/ 推荐使用lib文件夹下的proguard.jar,从命令行启动该工具“java -jar .../lib/proguard.jar @混淆配置文件” 对代码进行混淆;图形界面proguardgui.jar在win下启动正常,ubuntu11.10启动失败( 没空追踪失败原因,放弃之, 读者若有兴趣可自行研究) 2. 上一条中的“混淆配置文件”是个神奇的好东东,在混淆的道路上起着举足轻重综合协调承前启后的作用,不好意思,我墨迹了,我只是想强调它的重要性

How to automatically generate proguard-android.txt?

旧时模样 提交于 2019-12-01 06:33:02
Reading all the wonderful things the new ProGuard Improvements for Android do, I switched to to the new scheme by uncommenting the following line in a newly created project: proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt;proguard-project.txt But when I try to export this project's APK, I am greeted with the following message: Invalid proguard configuration file path C:\android-sdk-windows\tools\proguard\proguard-android.txt does not exist or is not a regular file Well, I checked the directory C:\android-sdk-windows\tools\proguard and, sure enough, while this directory exists

Android ProGuard how to hide/obfuscate source code of exported library

。_饼干妹妹 提交于 2019-12-01 06:30:44
I'm developing Android library and I want to hide/obfuscate the source code implementation of the library. The way the user project app will use the library is: startActivity( new Intent(context, LibraryActivityName.class) ); So I need to keep just the name of entry point Activity inside the library project, That's all. When I used the default ProGuard settings: buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } as well as the suggested example for library - Nothing happened, and by clicking on the Activity name

Android代码混淆ProGuard工作原理简介

故事扮演 提交于 2019-12-01 06:00:22
ProGuard能够对Java类中的代码进行压缩(Shrink),优化(Optimize),混淆(Obfuscate),预检(Preveirfy)。    1. 压缩(Shrink): 在压缩处理这一步中,用于检测和删除没有使用的类,字段,方法和属性。    2. 优化(Optimize): 在优化处理这一步中,对字节码进行优化,并且移除无用指令。    3. 混淆(Obfuscate): 在混淆处理这一步中,使用a,b,c等无意义的名称,对类,字段和方法进行重命名。    4. 预检(Preveirfy): 在预检这一步中,主要是在Java平台上对处理后的代码进行预检。 对于ProGuard执行流程图如下图所示:  ProGuard使用: ProGuard已集成到Android构建系统中,所以我们不用手动调用这个工具。我们可以选择在只发布模式下构建系统的时候再去运行ProGuard。   在AndroidStudio中我们需要将Proguard添加到gradle.build文件的构建类型当中。不过在我们创建一个Android工程的时候,系统已经自动为我们添加到了gradle.build中。 buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android

How to exclude a classes from being kept by proguard

雨燕双飞 提交于 2019-12-01 05:53:16
问题 I added the following line in my proguard config: -keep class com.mypackage.** {*;} But now proguard doesn't remove my class com.mypackage.BuildConfig.class from the result. And I want it to be removed. How can I exclude a given class from being kept? Thanks 回答1: You can use the following rule: -keep class !com.mypackage.BuildConfig, com.mypackage.** { *; } 来源: https://stackoverflow.com/questions/41060827/how-to-exclude-a-classes-from-being-kept-by-proguard