這是在工程中的proguard-project.txt中發現的javascript
# 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.htmlhtml
# Add any project specific keep options here:java
# 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 *;
#}android
Android代碼混淆,如何過濾掉反射的R文件及第三方包?
解決方案:在Proguard.cfg方件中添加如下設定:
web
過濾R文件的混淆:app
-keep class **.R$* { *; }
eclipse
過濾第三方包的混淆:ide
-keep class packagename.** {*;}(其中packagename爲第三方包的包名)
Android導入第三方jar包,proguard混淆腳本(屏蔽警告,不混淆第三方包)
最近1個項目中 須要導入移動MM的第三方計費包,混淆時用到了以下腳本,可屏蔽警告,不混淆第三方包指定內容。
很是有效
proguard.cfg 文件
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-ignorewarnings //這1句是屏蔽警告,腳本中把這行註釋去掉
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
//這1句是導入第三方的類庫,防止混淆時候讀取包內容出錯,腳本中把這行註釋去掉
-libraryjars libs/mmbilling.jar 函數
-dontwarn //dontwarn去掉警告
-dontskipnonpubliclibraryclassmembersui
-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.**