Android代码混淆和项目宣布步骤记录器
原本放在一起Android项目与发布的文件相混淆。我突然想到,为什么不写博客,分享。有这篇文章的情况下,。
Android代码混淆及项目公布步骤记录
一、清理代码中的调试信息,如Log、System.out
二、在清单文件里改动版本号为当前版本号,假设须要更新数据库,则须要在配置类或配置文件里改动程序数据库版本号。
三、在清单文件里将项目的debugable设置为false
四、创建签名证书keystore文件
五、在项目中的project.properites文件里加入语句proguard.config=proguard-project.txt来指定混淆规则文件
六、配置proguard-project.txt文件
七、假设项目引用了Library Project。则Eclipse应该会在project.properties文件里自己主动生产android.library.reference.1..n=../LibraryProjectName
八、假设项目中包括svntmp(通常位于项目的bin目录下)。在打包时应及时删除,否则会导致打包失败。
九、项目打包,安装測试(最好是使用现有生成包进行升级測试)
附:演示样例proguard-project.txt文件及对应说明:
# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
# Optimizations: If you don't want to optimize, use the
# proguard-android.txt configuration file instead of this one, which
# turns off the optimization flags. Adding optimization introduces
# certain risks, since for example not all optimizations performed by
# ProGuard works on all versions of Dalvik. The following flags turn
# off various optimizations known to have issues, but the list may not
# be complete or up to date. (The "arithmetic" optimization can be
# used if you are only targeting Android 2.0 or later.) Make sure you
# test thoroughly if you go this route.
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
-optimizationpasses 5
-allowaccessmodification
-dontpreverify
#-dontoptimize
# The remainder of this file is identical to the non-optimized version
# of the Proguard configuration file (except that the other file has
# flags to turn off optimization).
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-keepattributes Signature
-verbose
-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
-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}
# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
#-keepclassmembers public class * extends android.view.View {
# void set*(***);
# *** get*();
#}
# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class **.R$* {
*;
}
# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-keep class * extends android.view.View{*;}
-keep class * extends android.app.Dialog{*;}
-keep class * implements java.io.Serializable{*;}
#-ignorewarnings
-libraryjars libs/locSDK_4.1.jar
-libraryjars libs/pinyin4j-2.5.0.jar
-libraryjars libs/libammsdk.jar
-libraryjars libs/WebtrendsAndroidClientLib.jar
#-libraryjars libs/afinallib.jar
#-libraryjars libs/stickylistheaders_lib.jar
-keep class android.support.v4.** {*;}
-keep class com.emilsjolander.** {*;}
-keep class org.kobjects.** {*;}
-keep class org.kxml2.** {*;}
-keep class org.xmlpull.** {*;}
-keep class net.tsz.** {*;}
-keep class com.hp.** {*;}
-keep class com.baidu.** {*;}
-keep class net.sourceforget.** {*;}
-keep class com.tencent.** {*;}
-dontwarn demo.**
-keep class demo {*;}
-keep class com.wly.xxx.bean.** {*;}
-keep class com.wly.xxx.tool.DbModelUtils{*;}
-keep class com.wly.xxx.tool.JsonUtils{*;}
-keep class com.wly.xxx.activity.InsuranceQuotesActivity
-keep public class com.wly.xxx.activity.InsuranceQuotesActivity$MyJavaScriptInterface
-keep public class * implements com.wly.xxx.activity.InsuranceQuotesActivity$MyJavaScriptInterface
-keepclassmembers class com.wly.xxx.activity.InsuranceQuotesActivity$MyJavaScriptInterface {
public *;
private *;
}
文件说明:
0.以上文件拷贝自笔者如今开发的项目。出于项目保护的目的,已将project包名替换com.wly.xxx,读者能够依据自己的项目加以改动!
1.蓝色内容具有通用性质,能够复制黏贴;
2.橙色内容用于指定程序中用到的jar文件(能够看到引用的Library Project不需包括,由于他们已经在project.properties文件里指定了)。
3.红色内容用于表示保留(不混淆)引用的jar包中的内容。
4.草绿色内容用于表示保留本地的bean文件下的实体类不被混淆。
5.紫色内容用于表示保留本地涉及反射的类不被混淆。
6.绿色内容用于特别处理Web JS当地土著调用进程不应被组件之间的混淆。
版权声明:本文博客原创文章。博客,未经同意,不得转载。
Android代码混淆和项目宣布步骤记录器的更多相关文章
- Android代码混淆及项目发布方法记录
Android代码混淆及项目发布步骤记录 本来整理了一份Android项目混淆与发布的文档,突然想到何不写篇博客,分享一下呢,如是便有了本文. Android代码混淆及项目发布步骤记录 一.清理 ...
- Android 代码混淆 混淆方案
本篇文章:自己在混淆的时候整理出比较全面的混淆方法,比较实用,自己走过的坑,淌出来的路.请大家不要再走回头路,可能只要我们代码加混淆,一点不对就会导致项目运行崩溃等后果,有许多人发现没有打包运行好好地 ...
- Android 代码混淆规则
1. Proguard介绍 Android SDK自带了混淆工具Proguard.它位于SDK根目录toolsproguard下面.ProGuard是一个免费的Java类文件收缩,优化,混淆和预校验器 ...
- Android代码混淆官方实现方法
首先查看一下 “project.properties” 这个文件: # This file is automatically generated by Android Tools.# Do not m ...
- Android 代码混淆 防止反编译
为了防止代码被反编译,因此需要加入混淆.混淆也可以通过第三方进行apk混淆,也可以用android中的proguard进行混淆. 混淆步骤: 1.配置混淆文件,名字可以随意,在这里使用proguard ...
- android 代码混淆及问题大集锦
最近在需要对所开发的项目进行了代码混淆,在android studio中开启代码混淆其实还是挺方便的,不过因为代码混淆产生的问题非常多,特别是对于一些涉及到反射的第三方库经常因为名称的变化导致无法使用 ...
- 简单Android代码混淆(转)
代码混淆步骤: 1,project.properties中打开代码混淆功能,加入proguard.config=proguard.cfg 2,编辑proguard.cfg文件,项目没有自动生成时可手工 ...
- Android 代码混淆、Android Proguard(混淆)
Android Proguard(混淆) 混淆(Proguard)用法 最近项目中遇到一些混淆相关的问题,由于之前对proguard了解不多,所以每次都是面向Stackoverflow的编程.co ...
- Android 代码混淆、第三方平台加固加密、渠道分发 完整教程(图文)
第一步:代码混淆(注意引入的第三方jar) 在新版本的ADT创建项目时,混码的文件不再是proguard.cfg,而是project.properties和proguard-project.txt. ...
随机推荐
- [转]linux下iftop工具的安装与使用详解(图文)——实时的网络流量,监控TCP/IP连接(单机)
原文链接:http://www.jbxue.com/LINUXjishu/10735.html 在linux中监控系统资源.进程.内存占用等信息,可以使用top命令.查看网络状态可以使用netstat ...
- [转]apache下htaccess不起作用,linux,windows详解
可能出现下面这三种的错误可能性: 第一种:启用 rewrite 和 .htaccess 设置 rewrite设置:找到apache的配置文件httpd.conf文件,找到:#LoadModule re ...
- Jquery学习笔记:操作form表单元素之一(文本框和下拉框)
一.概述 在web页面开发中,经常需要获取和设置表单元素的值(如文本框中的内容),特别是在ajax应用中,更是常态.本文系统的介绍下如何操作. 同操作其它html元素一样,操作的过程差不多. 第一步, ...
- RVCT的Linux环境变量配置 ARM® RVDS™ 4.1(b713)
下载解压 armrvds.tar.gz到/opt 下 在自己的build.sh下导入RVCT的环境变量配置ARM® RVDS™4.1(b713): export ARMROOT=/opt/armrvd ...
- (读书笔记).NET大局观-.NET框架类库概观
.NET框架类库概况 构建在.NET框架上所有的软件,都会用到通用语言进行时,即使基于最简单的CLR程序,也需要用到一部分.NET框架类库,更精致复杂的软件则使用这个类库提供的更多服务. .NET框架 ...
- TCP/IP笔记 三.运输层(1)——UDP,TCP
1. 运输层 1.1 两种协议:TCP和UDP. (1)TCP:提供了一种可靠的数据传输服务,TCP是面向连接的,只有链接建立起来后才能通信. (2)UDP:是把数据直接发出去,而不管对方是不是在收信 ...
- php:兄弟连之面向对象版图形计算器2
上篇说到通过result.class.php来分流,因为三个类都继承了shape这个类,让我们来看一下,面向对象中的继承. shape.class.shape文件 <?php abstract ...
- XLSTransformer生成excel文件简单演示样例
项目结构图: 项目中所用到的jar,能够到http://www.findjar.com/index.x下载 ExcelUtil类源代码: package util; import java.io.IO ...
- 64位与32位编程的数据类型区别(C/C++)
C/C++仅仅定义了这些基本数据类型之间的关系,并没有定义严格定义它们的字长.在不同的平台上,根据编译器不同的实现,它们的字长如下表所示: 数据类型 LP64 ILP64 LLP64 ILP32 LP ...
- Troubleshooting:lvm调整分区时“Error parsing metadata for VG fedora”的解决
磁盘满了,由于使用的是lvm,想要扩容时发现无论lvs还是lvdisplay这类命令都会报同样的错: [root@localhost qwang]# lvs Parse error at (line ...