简体   繁体   English

Android使用proguard保护应用程序

[英]Android protect app with proguard

I've created my app and following the suggestions here I've done this: 我已经创建了我的应用程序并按照这里的建议完成了这个:

In proguard-project.txt: 在proguard-project.txt中:

# 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 10
-dontwarn android.support.**
-verbose


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

-keep public class ClassOne extends Activity
-keep public class ClassTwo extends ListActivity
-keep public class ClassThree extends ListActivity
-keep public class ClassFour extends ListActivity
-keep public class ClassFive extends ListActivity
-keep public class ClassSix extends ListActivity
-keep public class ClassSeven extends Activity

Those are the class on my manifest 这些是我的manifest上的课程

In project.properties uncomment the line: 在project.properties中取消注释该行:

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

I've exported my app and opened used dex2jar and jd-gui to see if add any success. 我已导出我的应用程序并打开使用dex2jar和jd-gui以查看是否添加任何成功。

The problem is that the code is almost as I've coded and is very easy to understand. 问题是代码几乎和我编码一样,很容易理解。

Am I doing something wrong? 难道我做错了什么? Can I improve the obfuscation? 我可以改进混淆吗?

You should have copied the 'keeps' literally as in 你应该按字面意思复制'keep'

-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 com.android.vending.licensing.ILicensingService
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Fragment

rather than substituting your own actual activity names 而不是替换您自己的实际活动名称

Ok. 好。

I've removed the lines: 我删除了这些行:

-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 com.android.vending.licensing.ILicensingService
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Fragment

And now its as I expected 现在正如我所料

Since all examples on the internet have those lines I tough they were important. 由于互联网上的所有例子都有我强硬的那些线条,因此它们很重要。

Testing my app and it is working as expected 测试我的应用程序,它正在按预期工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM