Android app的混淆打包

  • android app的 混淆打包,详细教程见app混淆打包教程
  • 根据以上的教程,我也给我的app做了一个混淆打包,反编译之后,发现的确混淆成功,并且运行正常。
  • 我的app里面的代码比较简单,用到了第三方jar只有gson.
  • 于是我的proguard-project.txt是这样的:
# 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.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 *;
#}
#######################################################


################gson################## 
-libraryjars libs/gson-2.2.1.jar
-keep class com.google.gson.** {*;}  
-keep class sun.misc.Unsafe { *; }  
-keep class com.google.gson.stream.** { *; }  
-keep class com.google.gson.examples.android.model.** { *; }   
-keep class com.google.** {  
    <fields>;  
    <methods>;  
}  
-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();  
}  
-dontwarn com.google.gson.**  


################common###############  
-keep class com.duck.smsCHeck.bean.** {*;}

  • 我的project.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 edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-20
android.library.reference.1=../appcompat_v7
  • 只有这两个文件配置好了,然后就是右键导出为android app。一路next,添加或生成一个keystore文件这样就生成了一个混淆过的apk文件。


  • 附上我的导出之后的工程。导出之后的工程

  • 顺便介绍一下工程的内容。主要是我之前的一个需求:短信验证的校验。
    • 主要逻辑:发送请求给第三方平台(我这里用的是云之讯),然后,请求正确,手机就会收到一个验证码短信。读取该短信,判断其中验证码与生成的验证码是否相同,如果相同,验证通过。其他任何情况,验证不通过。然后,删除该验证码短信。(5.0以后的手机不能完成这一步).
    • 里面的代码就不解释了,和上一篇相同。这里只是在之前的工程的基础上做了一个混淆打包。
    • 关于如何将部分java代码导出生成混淆过的jar,这个还没有弄过,在搜索中…..
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值