Android工程混淆打包:一個典型過程和樣本檔案

來源:互聯網
上載者:User

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













AndroidManifest.xml" />

















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












聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.