簡體   English   中英

Android使用proguard保護應用程序

[英]Android protect app with proguard

我已經創建了我的應用程序並按照這里的建議完成了這個:

在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

這些是我的manifest上的課程

在project.properties中取消注釋該行:

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

我已導出我的應用程序並打開使用dex2jar和jd-gui以查看是否添加任何成功。

問題是代碼幾乎和我編碼一樣,很容易理解。

難道我做錯了什么? 我可以改進混淆嗎?

你應該按字面意思復制'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

而不是替換您自己的實際活動名稱

好。

我刪除了這些行:

-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

現在正如我所料

由於互聯網上的所有例子都有我強硬的那些線條,因此它們很重要。

測試我的應用程序,它正在按預期工作

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM