2013-02-11 55 views
2

我的項目在android設備和模擬器上工作正常。當在android中啓用proguard時,應用程序無法正常工作

但是,如果我在導出proguard應用程序後啓用並導出.apk文件,我無法安裝帶有proguard的.apk文件。

我的假設,安裝.apk文件時未調用服務,並且我的日誌中沒有出現任何錯誤。

請分享您的想法。

這是我的proguard文件。

-optimizationpasses 5 
-dontskipnonpubliclibraryclasses 
-dontskipnonpubliclibraryclassmembers 
-dontpreverify 
-verbose 
-dontoptimize 
# -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 
-libraryjars /usr/local/android-sdk/add-ons/google_apis-7_r01/libs/maps.jar 

-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 

-keepattributes JavascriptInterface 

-keepclasseswithmembers class * { 
    public <init>(android.content.Context, android.util.AttributeSet); 
} 
-keepclasseswithmembers class * { 
    public <init>(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 *; 
} 
-keep class mypackage.MyCallbackClass { 
    void myCallbackMethod(java.lang.String); 
} 

-dontwarn android.support.** 
-dontwarn org.w3c.dom.bootstrap.DOMImplementationRegistry 

和我** 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 
#proguard.config=proguard.cfg 
# Project target. 
target=Google Inc.:Google APIs:11 
android.library.reference.1=../Library1 
android.library.reference.2=../Library2 

敬請分享您的想法。

謝謝。

回答

0

我想你是用一個釋放鍵簽署這個版本的。 如果您的手機已安裝舊版本(帶有調試密鑰),請先將其卸載(您的設備上不能有兩個不同的簽名)

+0

感謝您的回覆文斯。我是通過命令提示符使用「adb uninstall myProject.apk」從設備上卸載應用程序的。但是在啓動頁面時會卡住。現在,我可以查看這個錯誤「!!!失敗的BINDER TRANSACTION !!!」在我的日誌上。 – vinoth 2013-02-11 10:58:23

0

失敗的BINDER TRANSACTION通常會在您已經溢出了Binder進程。如果你沒有在你的啓動頁面上使用大的位圖(這是失敗的綁定事務處理最常見的原因),那麼它可能是ParcelFormatException,因爲我注意到你正在嘗試在你的apk中使用Parcelable。

0

假設你保持ADT最新..

如果您正在構建使用Eclipse導出應用程序的發行版,它會從被proguard.config財產project.properties指定的文件加載Proguard的設置。

如果您使用的是ant release,它將從ant.properties中的proguard.config屬性指定的文件加載Proguard設置。

這就是說,你是否在構建過程中遇到任何類型的錯誤或警告?這些在診斷Proguard時特別有用,因爲它的目的是刪除它不包含的類和方法認爲正在被您的應用程序使用。

我使用卸載我的應用程序:

adb shell pm uninstall -k com.*example*.*app* 

,並重新安裝使用:

adb install App-release.apk 

如果它提供了有關兼容性的錯誤,我放棄了以前的應用程序數據從卸載不含-k開關命令:

adb shell pm uninstall com.*example*.*app* 
相關問題