我刚刚开发了我的应用程序并希望发布但在此之前我想删除日志和其他不必要的东西。我发现使用Proguard的最佳方式。我使用命令行,所以我使用命令ant release
,我的应用程序成功构建,在/ bin目录中生成的新apk文件是<app-name>-release.apk
。我在我的设备中安装了apk,但是在几个屏幕后它崩溃了,当我尝试重新设置我的应用程序并移动到其他标签时,它在某些时候崩溃了。
不知道为什么会这样。所以这是我的project.properties
文件的包含
target=android-15
proguard.config=proguard-project.txt
这是我的proguard-project.txt
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-libraryjars smack.jar
-libraryjars libphonenumber-5.0v1.5.jar
#-keep class com.** { *; }
#-keep class org.** { *; }
-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
-keepclasseswithmembernames class * {
native <methods>;
}
-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 *;
}
错误日志:
10-08 07:25:18.356: E/AndroidRuntime(1733): FATAL EXCEPTION: Contact_sync_Service
10-08 07:25:18.356: E/AndroidRuntime(1733): java.lang.NoClassDefFoundError: com.google.i18n.phonenumbers.PhoneNumberUtil
10-08 07:25:18.356: E/AndroidRuntime(1733): at org.sipchat.sipua.ui.ai.run(Unknown
Source)
10-08 07:25:18.356: E/AndroidRuntime(1733): at java.lang.Thread.run(Thread.java:856)
10-08 07:26:26.756: E/dalvikvm(1751): Could not find class 'org.jivesoftware.smack.filter.MessageTypeFilter', referenced from method org.sipchat.sipua.ui.ConnectionService.a
10-08 07:26:26.786: E/dalvikvm(1751): Could not find class 'org.jivesoftware.smack.ConnectionConfiguration', referenced from method org.sipchat.sipua.ui.ConnectionService.onStartCommand
10-08 07:26:26.806: E/dalvikvm(1751): Could not find class 'org.jivesoftware.smack.ConnectionConfiguration', referenced from method org.sipchat.sipua.ui.af.run
10-08 07:26:26.956: E/AndroidRuntime(1751): FATAL EXCEPTION: main
10-08 07:26:26.956: E/AndroidRuntime(1751): java.lang.NoClassDefFoundError: org.jivesoftware.smack.ConnectionConfiguration
10-08 07:26:26.956: E/AndroidRuntime(1751): at org.sipchat.sipua.ui.ConnectionService.onStartCommand(Unknown Source)
10-08 07:26:26.956: E/AndroidRuntime(1751): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2359)
10-08 07:26:26.956: E/AndroidRuntime(1751): at android.app.ActivityThread.access$1900(ActivityThread.java:123)
10-08 07:26:26.956: E/AndroidRuntime(1751): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
10-08 07:26:26.956: E/AndroidRuntime(1751): at android.os.Handler.dispatchMessage(Handler.java:99)
10-08 07:26:26.956: E/AndroidRuntime(1751): at android.os.Looper.loop(Looper.java:137)
10-08 07:26:26.956: E/AndroidRuntime(1751): at android.app.ActivityThread.main(ActivityThread.java:4424)
10-08 07:26:26.956: E/AndroidRuntime(1751): at java.lang.reflect.Method.invokeNative(Native Method)
10-08 07:26:26.956: E/AndroidRuntime(1751): at java.lang.reflect.Method.invoke(Method.java:511)
10-08 07:26:26.956: E/AndroidRuntime(1751): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-08 07:26:26.956: E/AndroidRuntime(1751): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-08 07:26:26.956: E/AndroidRuntime(1751): at dalvik.system.NativeStart.main(Native Method)
更新:
错误提到的包是我在proguard-project.txt
已添加的jar文件包
如果我在任何地方出错,请告诉我吗?
谢谢
答案 0 :(得分:1)
你有没有试过Dexguard?正如它在proguard网站上所说的
ProGuard现在有一个适用于Android的兄弟优化器和混淆器: DexGuard。它与ProGuard兼容,并提供额外的功能 字符串加密,类加密和隐藏访问等功能 敏感的API。它直接针对Dalvik字节码和流线型 Android构建过程。