Android之混淆代码总结

为了防止自己的劳动成果被别人窃取,混淆代码能有效防止被反编译,下面来总结以下混淆代码的步骤:

1. 大家也许都注意到新建一个工程会看到项目下边有这样proguard-project.txt一个文件,这个对混淆代码很重要,如果你不小心删掉了,没关系,从其他地方拷贝一个过来

2. 最重要的就是在proguard-project.txt添加混淆的申明了:

    a. 把所有你的jar包都申明进来,例如:

-libraryjars libs/apns_1.0.6.jar-libraryjars libs/armeabi/libBaiduMapSDK_v2_3_1.so-libraryjars libs/armeabi/liblocSDK4.so
-libraryjars libs/baidumapapi_v2_3_1.jar
-libraryjars libs/core.jar
-libraryjars libs/gesture-imageview.jar
-libraryjars libs/gson-2.0.jar
-libraryjars libs/infogracesound.jar
-libraryjars libs/locSDK_4.0.jar
-libraryjars libs/ormlite-android-4.48.jar
-libraryjars libs/ormlite-core-4.48.jar
-libraryjars libs/universal-image-loader-1.9.0.jar
b. 将你不需要混淆的部分申明进来,因为有些类经过混淆会导致程序编译不通过,如下:
-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 * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class * extends android.support.v4.**
-keep public class com.android.vending.licensing.ILicensingService
--以上都是API里边的类,最好都要避免混淆
有些很特殊的,例如百度地图,你需要添加以下申明:
-keep class com.baidu.** { *; } 
-keep class vi.com.gdi.bgl.android.**{*;}
根据我的经验,一般model最好避免混淆(model无关紧要,不混淆也没多大关系)如:
-keep class com.bank.pingan.model.** { *; }
下面在贴上关于Umeng分享统计的避免混淆的申明
-dontwarn android.support.v4.**  
-dontwarn org.apache.commons.net.** 
-dontwarn com.tencent.** 
-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 *;
}
-keepclasseswithmembers class * {public <init>(android.content.Context);
}
-dontshrink
-dontoptimize
-dontwarn com.google.android.maps.**
-dontwarn android.webkit.WebView
-dontwarn com.umeng.**
-dontwarn com.tencent.weibo.sdk.**
-dontwarn com.facebook.**
-keep enum com.facebook.**
-keepattributes Exceptions,InnerClasses,Signature
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public interface com.facebook.**
-keep public interface com.tencent.**
-keep public interface com.umeng.socialize.**
-keep public interface com.umeng.socialize.sensor.**
-keep public interface com.umeng.scrshot.**
-keep public class com.umeng.socialize.* {*;}
-keep public class javax.**
-keep public class android.webkit.**
-keep class com.facebook.**
-keep class com.umeng.scrshot.**
-keep public class com.tencent.** {*;}
-keep class com.umeng.socialize.sensor.**
-keep class com.tencent.mm.sdk.openapi.WXMediaMessage {*;}
-keep class com.tencent.mm.sdk.openapi.** implements com.tencent.mm.sdk.openapi.WXMediaMessage$IMediaObject {*;}
-keep class im.yixin.sdk.api.YXMessage {*;}
-keep class im.yixin.sdk.api.** implements im.yixin.sdk.api.YXMessage$YXMessageData{*;}
-keep public class [your_pkg].R$*{public static final int *;
}

3.以上工作完成,混淆工作就完成了一大半了,最后需要做的就是在project.properties文件中加上你的混淆文件申明了,如下:
   proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

4. OK, 最后一步,打签名包测试,如果有问题,仔细看下Log也许有得类不能混淆,那么你得加入到proguard-project.txt文件中
-------以上就是混淆代码的全过程了


最后贴上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 *;
#}
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*-keepattributes *Annotation*
-keepattributes Signature-libraryjars libs/apns_1.0.6.jar
-libraryjars libs/armeabi/libBaiduMapSDK_v2_3_1.so
-libraryjars libs/armeabi/liblocSDK4.so
-libraryjars libs/baidumapapi_v2_3_1.jar
-libraryjars libs/core.jar
-libraryjars libs/gesture-imageview.jar
-libraryjars libs/gson-2.0.jar
-libraryjars libs/infogracesound.jar
-libraryjars libs/locSDK_4.0.jar
-libraryjars libs/ormlite-android-4.48.jar
-libraryjars libs/ormlite-core-4.48.jar
-libraryjars libs/universal-image-loader-1.9.0.jar-keep class com.baidu.** { *; } 
-keep class vi.com.gdi.bgl.android.**{*;}-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 * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class * extends android.support.v4.**
-keep public class com.android.vending.licensing.ILicensingService-keep class com.google.gson.stream.** { *; }
-keep class com.google.gson.examples.android.model.** { *; }
-keep class com.uuhelper.Application.** { *; }
-keep class net.sourceforge.zbar.** { *; }
-keep class com.google.android.gms.** { *; } -keep class com.bank.pingan.model.** { *; }-keep public class * extends com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper
-keep public class * extends com.j256.ormlite.android.apptools.OpenHelperManager-keep class com.android.vending.licensing.ILicensingService
-keep class android.support.v4.** { *; }  
-keep class org.apache.commons.net.** { *; }  
-keep class com.tencent.** { *; }  -keep class com.umeng.** { *; }  
-keep class com.umeng.analytics.** { *; }  
-keep class com.umeng.common.** { *; }  
-keep class com.umeng.newxp.** { *; }  -keep class com.j256.ormlite.** { *; }  
-keep class com.j256.ormlite.android.** { *; }  
-keep class com.j256.ormlite.field.** { *; }  
-keep class com.j256.ormlite.stmt.** { *; } -dontwarn android.support.v4.**  
-dontwarn org.apache.commons.net.** 
-dontwarn com.tencent.**  -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 *;
}-keepclasseswithmembers class * {public <init>(android.content.Context);
}-dontshrink
-dontoptimize
-dontwarn com.google.android.maps.**
-dontwarn android.webkit.WebView
-dontwarn com.umeng.**
-dontwarn com.tencent.weibo.sdk.**
-dontwarn com.facebook.**-keep enum com.facebook.**
-keepattributes Exceptions,InnerClasses,Signature
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable-keep public interface com.facebook.**
-keep public interface com.tencent.**
-keep public interface com.umeng.socialize.**
-keep public interface com.umeng.socialize.sensor.**
-keep public interface com.umeng.scrshot.**-keep public class com.umeng.socialize.* {*;}
-keep public class javax.**
-keep public class android.webkit.**-keep class com.facebook.**
-keep class com.umeng.scrshot.**
-keep public class com.tencent.** {*;}
-keep class com.umeng.socialize.sensor.**-keep class com.tencent.mm.sdk.openapi.WXMediaMessage {*;}-keep class com.tencent.mm.sdk.openapi.** implements com.tencent.mm.sdk.openapi.WXMediaMessage$IMediaObject {*;}-keep class im.yixin.sdk.api.YXMessage {*;}
-keep class im.yixin.sdk.api.** implements im.yixin.sdk.api.YXMessage$YXMessageData{*;}-keep public class [your_pkg].R$*{public static final int *;
}
2015-05-25更新

1. 依赖工程的jar 申明:

	以下是邮件发送的实例

   -libraryjars ../KlowerBase/libs/mail-activation.jar-libraryjars ../KlowerBase/libs/mail-additionnal.jar-libraryjars ../KlowerBase/libs/mail.jar

2. 解决邮件发送时报的以异常

   -keep class javax.mail.**{*;}-keep class com.sun.mail.**{*;}-keep class javax.activation.**{*;}-keep class org.apache.harmony.**{*;}-keep class java.security.**{*;}

#解决:can't find referenced class java.beans.Beans
-dontwarn org.apache.commons.collections.BeanMap
-dontwarn java.beans.**
#解决:can't find referenced class javax.security.sasl.Sasl
-dontwarn com.sun.mail.imap.protocol.**




本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/295065.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

SRM 588 D2 L2:GUMIAndSongsDiv2,冷静思考,好的算法简洁明了

题目来源&#xff1a;http://community.topcoder.com/stat?cproblem_statement&pm12707 算法决定一切&#xff0c;这道题目有很多方法解&#xff0c;个人认为这里 vexorian 给出的解法最简便&#xff0c;编码也最容易。而使用brute force 和 DP都比较复杂。 代码如下&…

android textview 中超出屏幕宽度的字符 省略号显示

2019独角兽企业重金招聘Python工程师标准>>> 当利用textview显示内容时&#xff0c;显示内容过多可能会折行或显示不全&#xff0c;那样效果很不好。今天发现android api中已经给出自动省略的功能。 实现如下&#xff1a; <TextView android:layout_width"f…

linux 系统迁移到固态硬盘,把Debian GNU/Linux迁移到SSD上

首先&#xff0c;还是sudo gparted把SSD分两个区&#xff0c;一个用作/一个用作/home。然后把文件都复制过去。当然/dev/media /mnt /proc /run /sys /tmp这几个目录就不要复制过去了&#xff0c;在SSD上建立个新的同名目录。ls -l/dev/disk/by-uuid看看uuid对应的是哪个盘&…

世界各国的教育差距有多大?这几部全世界都在热议的教育纪录片,揭开一切.........

全世界只有3.14 % 的人关注了爆炸吧知识BBC纪录片《人生七年》里讲到&#xff1a;人无法确定能留给下一代什么财物&#xff0c;但至少可以确定&#xff0c;一旦给了他们好的教育&#xff0c;他们终生都可以受用。但是这世界上从来没有一个学校去教我们要如何为人父母&#xff0…

助力 .NET MAUI Community Toolkit

微软中国MSDN 点击上方蓝字关注我们最近&#xff0c;我们推出了.NET MAUI Community Toolkit&#xff0c;并且现在已做好了接受社区贡献的准备。我们修改了添加新功能的工作流程&#xff0c;在此分享给各位&#xff0c;以方便大家今后继续完善&#xff0c;做出贡献。我们还为此…

Android之可伸缩的皮筋效果(贝塞尔曲线)的介绍

贝塞尔曲线 引言:  为什么我要写这篇关于贝塞尔曲线的博客,在android里面很多地方都用到了,比如当我们看到一个效果像橡皮筋拉伸一样,有弹性,一般就会用到贝赛尔曲线,不知道细心的你有没有发现,比如,我们看到QQ里面有那个红色的气泡的可以按着拖动,还有一些…

Oracle错误:ORA-27121: unable to determine size of shared memory segment

为什么80%的码农都做不了架构师&#xff1f;>>> 今天在用SQLPLUS登陆数据库时&#xff0c;忽然报了一个错误&#xff0c;错误的代码如下&#xff1a; ORA-01034: ORACLE not availableORA-27121: unable to determine size of shared memory segmentLinux Error: 1…

Html中value和name属性的作用

1.按钮中用的value 指的是按钮上要显示的文本 比如“确定”“删除”等 2.复选框用的value 指的是这个复选框的值 3.单选框用的value 和复选框一样 4.下拉菜单用的value 是列表中每个子项的值 5.隐藏域用的value 是框里面显示的内容 在后台如果你想得到复选框的内容 就是value …

POJ 3264 Balanced Lineup(RMQ)

Balanced LineupTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 24349 Accepted: 11348Case Time Limit: 2000MSDescription For the daily milking, Farmer Johns N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to …

.NET 开源免费图表组件库,Winform,WPF 通用

大家好, 我是等天黑, 今天给大家介绍一个功能完善, 性能强悍的图表组件库 ScottPlot, 当我第一次在 github 上看到这个库, 我看不懂&#xff0c;但我大受震撼, 这么好的项目当然要分享出来了。https://github.com/ScottPlot/ScottPlotScottPlot 是一个 .NET 图表组件, 主要有以…

物理学上最厉害的54个男人!2400年来难以超越,没想到聚在一起后这么震撼......

全世界只有3.14 % 的人关注了爆炸吧知识19世纪的最后一天电子的发现者汤姆生发表了新年祝词&#xff1a;“晴朗的天空远处&#xff0c;有两朵令人不安的乌云令物理学的优美性和明晰性黯然失色”也似乎就是从这一天开始经典力学的地位被撼动了原子的大门打开了这场微观世界的探险…

linux主线程结束 子线程还能运行么,linux主线程和子线程

"读了三遍&#xff0c;愣是没读懂楼主想说啥。######java_zf 我现在在做的一个项目用到了多线程&#xff0c;我就在项目中子线程调用的一个函数中加了个sleep。你可以写个简单的代码试一下&#xff0c;应该比较简单。你试验的结果不一样吗&#xff1f;我这个项目是Linux下…

Android插件化开发基础之Java反射机制研究

一、获得Class对象 Class<?> c Class.forName("classname"); 抛出ClassNotFoundException 二、获得实现接口 Class<?> inters[] c.getInterfaces(); for(int i0;i<inters.length;i){System.out.print(inters[i].getName()" "); …

[MySQL]关于amd.dll后门病毒入侵3306端口的临时解决方案

为什么80%的码农都做不了架构师&#xff1f;>>> amd.dll入侵事宜&#xff1a; 由于MySQL 5.1.30以上版本的一个漏洞&#xff08;当然是不是因为漏洞的原因&#xff0c;目前暂未知&#xff09;&#xff0c;导致一个后门程序会通过3306端口的MySQL服务获取到Windows…

微软将终止免费的条码标签服务

本文转自&#xff1a;慧都控件网 http://***/zh-CN/info/catalog/19420.html 在纽约时间2013年8月19号&#xff0c;Scanbuy——这个手机软件巨头&#xff0c;手机移动设备的条形码解决方案提供商&#xff0c;被微软选中成为微软条码标签的授权使用者。在购买了微软条码标签技术…

Spring Security3源码分析-http标签解析(转)

为什么80%的码农都做不了架构师&#xff1f;>>> 在FilterChainProxy初始化的过程中&#xff0c;大概描述了标签解析的一些步骤&#xff0c;但不够详细 <http auto-config"true"> <remember-me key"workweb" token-validity-se…

Android之React Native 中组件的生命周期

React Native 中组件的生命周期 概述 就像 Android 开发中的 View 一样&#xff0c;React Native&#xff08;RN&#xff09; 中的组件也有生命周期&#xff08;Lifecycle&#xff09;。所谓生命周期&#xff0c;就是一个对象从开始生成到最后消亡所经历的状态&#xff0c;理解…

当女朋友学会「监视」男朋友......

1 日本网友拍到两只水母互殴&#xff01;▼2 打印机也会生气&#xff1f;&#xff08;素材来源网络&#xff0c;侵删&#xff09;▼3 现在你们可以互换卡槽了~&#xff08;素材来源网络&#xff0c;侵删&#xff09;▼4 有什么适合整蛊朋友的恶作剧▼5 哈哈哈哈哈&#xff…

使用.NET5、Blazor和Electron.NET构建跨平台桌面应用

Electron.NET是一个嵌入了ASP.NET Core的Electron的封装&#xff0c;通过Electron.NET可以构建基于.NET5的跨平台的桌面应用&#xff0c;使得开发人员只需要使用ASP.NET Core和 Blazor就可以胜任桌面应用的开发工作。开发环境操作系统Windows/macOS/Linux.NET5.0npm创建新项目创…

蜗蜗 Linux内核芬妮下,201402 - 蜗窝科技

作者&#xff1a;wowo 发布于&#xff1a;2014-2-27 17:01分类&#xff1a;统一设备模型在“Linux内核的整体架构”中&#xff0c;蜗蜗有提到&#xff0c;由于Linux支持世界上几乎所有的、不同功能的硬件设备(这是Linux的优点)&#xff0c;导致Linux内核中有一半的代码是设备驱…