Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android工程混淆打包:一個典型過程和示例文件

Android工程混淆打包:一個典型過程和示例文件

編輯:關於Android編程

本例不含依賴工程的情況,如有依賴工程,請先導出為jar包再打包:

1. 基於Android 2.1以上版本;

2. 簽名的密鑰文件生成;

1). 創建證書:keytool -genkey -alias mykey.keystore -keyalg RSA -keystore mykey.keystore 密碼同系統登陸密碼
3). 查看證書庫:keytool -list -keystore mykey.keystore
4). 導出到證書文件:keytool -export -alias mykey.keystore -file mykey.crt -keystore mykey.keystore
5). 導入證書的信息:keytool -import -keystore mykey.keystore -file mykey.crt mykey.crt導入到名為mykey.keystore的證書庫中
6). 查看證書信息:keytool -printcert -file mykey.crt
7). 刪除密鑰庫中的條目:
keytool -list -keystore mykey.keystore
keytool -delete -keystore mykey.keystore -alias mykey.keystore
8). 修改證書條目的口令:keytool -keypasswd -alias mykey.keystore -keystore mykey.keystore

3. 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


#使用xml布局並且混淆apk時,請在混淆配置中加入以下這行代碼
-keep class com.mediav.** {*;}


-keepclasseswithmembernames class * {
native ;
}


-keepclasseswithmembers class * {
public (android.content.Context, android.util.AttributeSet);
}


-keepclasseswithmembers class * {
public (android.content.Context, android.util.AttributeSet, int);
}


-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}


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


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

4. Build.xml文件













































































































































Creating all output directories


















Generating R.java...































Compiling aidl files into Java classes...

































































Converting compiled files into ${intermediate-dex}...





















Packaging resources and assets...



































release:Packaging ${out-debug-package-ospath}, and signing it with a debug key...




































jarsigner ${out-signed-package-ospath}





























zipalign ${zipalign-package-ospath}





















Installing ${out-debug-package} onto default emulator...












  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved