博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Apk代码混淆
阅读量:6273 次
发布时间:2019-06-22

本文共 4611 字,大约阅读时间需要 15 分钟。

hot3.png

主要修改2个文件 default.properties 和 proguard.cfg

首先先看看原始文件的内容

 default.properties

# This file is automatically generated by Android Tools.

# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
# This file must be checked in Version Control Systems.
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-8
# Indicates whether an apk should be generated for each density.
split.density=false

 
proguard.cfg

-optimizationpasses 5

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-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>;
}
-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 *;
}

------------------------------------------------------------------------------

如果说你项目没有引用第三方包,就只要在default.properties 加入 proguard.config=proguard.cfg

# This file is automatically generated by Android Tools.

# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
# This file must be checked in Version Control Systems.
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-8
proguard.config=proguard.cfg
# Indicates whether an apk should be generated for each density.
split.density=false

如果有第三方包,则需要修改 proguard.cfg 忽略第三方包的混淆

-optimizationpasses 5

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-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>;
}
-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 *;
}
-ignorewarnings
-libraryjars lib/GuoTengTermb.jar
-libraryjars lib/ksoap2-android-assembly-2.4-jar-with-dependencies.jar
-libraryjars lib/httpmime-4.1.3.jar
-libraryjars lib/idreadsdk.jar
-libraryjars libs/MapApi.jar
-dontskipnonpubliclibraryclassmembers
-dontskipnonpubliclibraryclasses
-keep class org.kobjects.**{*;}
-keep class guoTeng.IC2ReadCard.**{*;}
-keep class com.fri.idcread.**{*;}
-keep class org.apache.http.entity.**{*;}
-keep class com.amap.mapapi.**{*;}
-keep class com.autonavi.aps.api.**{*;}
-keep class com.mapabc.minimap.map.vmap.**{*;}
-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
 }
 -keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    !static !transient <fields>;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
 }
-------------------------------------------------------------

这样导包apk时,就是代码混淆的的apk了

转载于:https://my.oschina.net/totome911/blog/112442

你可能感兴趣的文章
检验手机号码
查看>>
thinkphp3.1随机取数据库中几条记录
查看>>
重叠(Overlapped)IO模型
查看>>
ffmpeg study 1
查看>>
Git使用教程
查看>>
使用shell脚本自动监控后台进程,并能自动重启
查看>>
Flex&Bison手册
查看>>
java对象--继承的好处和特点
查看>>
MySQL 5.6 for Windows 解压缩版配置安装
查看>>
solrCloud+tomcat+zookeeper集群配置
查看>>
/etc/fstab,/etc/mtab,和 /proc/mounts
查看>>
Apache kafka 简介
查看>>
socket通信Demo
查看>>
技术人员的焦虑
查看>>
js 判断整数
查看>>
建设网站应该考虑哪些因素
查看>>
mongodb $exists
查看>>
js实现页面跳转的几种方式
查看>>
sbt笔记一 hello-sbt
查看>>
常用链接
查看>>