proguard.cfg 配置文件

http://stackoverflow.com/questions/8129040/proguard-missing-type-parameter

# -------------------------------------
# android 原始混淆模板
# -------------------------------------

# ----------------------------------
#  通过指定数量的优化能执行
#  -optimizationpasses n
# ----------------------------------
-optimizationpasses 5

# ----------------------------------
#   混淆时不会产生形形色色的类名
#   -dontusemixedcaseclassnames
# ----------------------------------
#-dontusemixedcaseclassnames
# ----------------------------------
#      指定不去忽略非公共的库类
#  -dontskipnonpubliclibraryclasses
# ----------------------------------
#-dontskipnonpubliclibraryclasses

# ----------------------------------
#       不预校验
#    -dontpreverify
# ----------------------------------
# -dontpreverify

# ----------------------------------
#      输出生成信息
#       -verbose
# ----------------------------------
-verbose

# ----------------------------------
#        优化选项
#   optimizations  {optimization_filter}
# ----------------------------------
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-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>;
}
# -----------------
# modify 修改合并
# -----------------
-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

#--------------------------
# 保护类型   -keepattributes 说明
# Exceptions, Signature, Deprecated, SourceFile, SourceDir, LineNumberTable, LocalVariableTable,
# LocalVariableTypeTable, Synthetic, EnclosingMethod, RuntimeVisibleAnnotations, RuntimeInvisibleAnnotations,
# RuntimeVisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations, and AnnotationDefault
# --------------------
-keepattributes **
-libraryjars <java.home>/lib/rt.jar

# ----------------------
#  不压缩指定的文件
#  -dontshrink
# ----------------------
-dontshrink

# ----------------------
#  不优化指定的文件
#  -dontoptimize
# -----------------------
-dontoptimize

# -----------------------
#  不混淆指定的文件
#  -dontobfuscate
# -----------------------

# ----- 混淆包路径 -------
-repackageclasses ‘‘
-flattenpackagehierarchy ‘‘
-target 1.6

# -------- 以下是使用了 roboguice-1.1.2.jar 以及 guice-2.0-no_app.jar 功能需要保护的字段及类相关 --------
-keep class com.google.inject.Binder
-keepclassmembers class * {
    @com.google.inject.Inject <init>(...);
}
-keepclassmembers class * {
    void *(**On*Event);
}
-keepclassmembers class **.R$* {
    public static <fields>;
}

# ------ 编译时需要用到的 jar 包
-libraryjars D:/dev_rc/android-sdk-windows/add-ons/addon_google_apis_google_inc_11/libs/maps.jar

# ------ 保护 谷歌第三方 jar 包,界面特效 ----------
-keep class android.support.v4.**
-dontwarn android.support.v4.**

# ------ 保护百度地址jar包 --------
-keep class com.baidu.mapapi.** { *; }
-dontwarn com.baidu.mapapi.**

# --- 打包时忽略以下类的警告 --
-dontwarn com.classpackage.AA

#-keepnames class * implements java.io.Serializable
# ---------保护所有实体中的字段名称----------
-keepclassmembers class * implements java.io.Serializable {
    <fields>;
}

# --------- 保护类中的所有方法名 ------------
-keepclassmembers class * {
    public <methods>;
}
##---------------Begin: proguard configuration common for all Android apps ----------
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose
-dump class_files.txt
-printseeds seeds.txt
-printusage unused.txt
-printmapping mapping.txt
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-allowaccessmodification
-keepattributes *Annotation*
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-repackageclasses ‘‘

-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
-dontnote com.android.vending.licensing.ILicensingService

# Explicitly preserve all serialization members. The Serializable interface
# is only a marker interface, so it wouldn‘t save them.
-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

# Preserve all native method names and the names of their classes.
-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);
}

# Preserve static fields of inner classes of R classes that might be accessed
# through introspection.
-keepclassmembers class **.R$* {
  public static <fields>;
}

# Preserve the special static methods that are required in all enumeration classes.
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep public class * {
    public protected *;
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}
##---------------End: proguard configuration common for all Android apps ----------

##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# Gson specific classes
-keep class sun.misc.Unsafe { *; }
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }

##---------------End: proguard configuration for Gson  ----------
时间: 2024-10-12 23:17:38

proguard.cfg 配置文件的相关文章

[Android Pro] proguard.cfg 配置文件

转载自:http://my.oschina.net/zhangzhihao/blog/72393 # ------------------------------------- # android 原始混淆模板 # ------------------------------------- # ---------------------------------- # 通过指定数量的优化能执行 # -optimizationpasses n # --------------------------

防反编译、混淆文件proguard.cfg与proguard-project.txt详解

在新版本的ADT创建项目时,混码的文件不再是proguard.cfg,而是project.properties和proguard-project.txt. 如果需要对项目进行全局混码,只需要进行一步操作: 将project.properties的中 “#  proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt”的“#”去掉就可以了. 如 果有一些代码不能被混淆,比如需要加入了so文件

我的grub.cfg配置文件

路径:/boot/grub/grub.cfg 配置文件如下: # # DO NOT EDIT THIS FILE # # It is automatically generated by grub-mkconfig using templates # from /etc/grub.d and settings from /etc/default/grub # ### BEGIN /etc/grub.d/00_header ### if [ -s $prefix/grubenv ]; then s

如何解决:新建Android程序的时候发生了找不到 \android-sdk-windows\tools\lib\proguard.cfg文件 的错误

问题概述: 在新建Android程序的时候出现以下错误: 找不到 \android-sdk-windows\tools\lib\proguard.cfg文件 原因: SDK不完整. 解决方法: 方法一 可在 \android-sdk-windows\tools\lib\目录下新建一个proguard.cfg文件 然后添下以下内容: proguard.cfg -optimizationpasses 5-dontusemixedcaseclassnames-dontskipnonpubliclibr

android 通过添加proguard.cfg文件实现代码混淆

若项目中没有proguard.cfg文件,手动添加 新建文本,输入以下代码 -dontwarn //若项目中导入了第三方jar包,需要添加该行 -optimizationpasses 5 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontpreverify -verbose -optimizations !code/simplification/arithmetic,!field/*,!class/merging/

Eclipse打包Android项目时用到proguard.cfg后,出现的Warning:can&amp;#39;t find referenced class问题的解决方式

Warning: can't find superclass or interface Warning: can't find referenced class 这两个问题的解决方法: 1.要把你项目中所引入的第三方jar包使用"-libraryjars 包路径"指定好. 2.还是报错的话,确保报错的类没有在你的项目中使用到,使用"-dontwarn 类名正則表達式"屏蔽警告. 完了?但是我还想问:第一步做完后还是报错,并且这个类在我项目中真的实用到,不能使用&qu

android 混淆文件proguard.cfg详解 (转载)

-injars  androidtest.jar[jar包所在地址] -outjars  out[输出地址] -libraryjars    'D:\android-sdk-windows\platforms\android-9\android.jar' [引用的库的jar,用于解析injars所指定的jar类] -optimizationpasses 5-dontusemixedcaseclassnames [混淆时不会产生形形色色的类名 ]-dontskipnonpubliclibraryc

通过telnet自动下载cfg配置文件

源代码如下: import telnetlib import logging import datetime import csv import time def telnetfunc(enbid, host, user, passwd): try: tn = telnetlib.Telnet(host) tn.read_until(b'login: ') tn.write(user.encode('ascii') + b'\n') tn.read_until(b'Password: ') tn

android 混淆文件proguard.cfg

1.ProGuard作用ProGuard通过删除无用代码,将代码中类名.方法名.属性名用晦涩难懂的名称重命名从而达到代码混淆.压缩和优化的功能,跟JavaScript的混淆压缩类似.压缩和优化使得编译后apk包更小.混淆可以保证代码在被反编译后读懂的难度很大,防止逆向工程.这点也是我们在应用发布前需要ProGuard的一大原因. 参考资料: http://www.trinea.cn/android/proguard-use/ 如果用eclipse export命令打包,会在<project_ro