"应用停止工作"使Proguard的后 [英] "Application stopped working" after enabling Proguard

查看:177
本文介绍了"应用停止工作"使Proguard的后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个工作的应用程序,无论是在模拟器,我测试的设备。

It was a working app, both on emulator and the device i am testing on.

但现在,我启用的 Proguard的并导出使用 Android的工具&gt签名的应用程序;出口签名的应用程序

But now, i enabled Proguard and Exported the signed app using Android-Tools > Export signed application

然后我复制这个 .apk文件到SD卡上,并试图安装在设备上。但是,应用程序停止工作,要求强制关闭,如果我尝试打开它。

Then i copied this .apk on to the SD card and tried to install on the Device. But the application stopped working, asking for force close if i try to open it.

它的工作原理在设备上,如果我从Eclipse中运行。

It works on the device if i run from Eclipse.

一直以来,公司称:

Proguard的只有效果,当你导出版本的apk文件。我检查,并在 APK 的bin文件夹中的文件大小为 1.8MB 其中的1我出口后,得到的是 1.4MB 。好像Proguard的已完成其工作。但是,应用程序无法正常工作。而可悲的是我看不到任何日志等。

Proguard has effect only when you export a release .apk file. I checked it, and the apk file size in the bin folder is 1.8mb where as the 1 i got after exporting is 1.4mb. Seems like Proguard has done its job. But the application is not working. And sadly i cannot see any logs etc..,

编辑:

如果我禁用Proguard的,然后出口,释放apk文件现在能正常工作。所以,有些问题Proguard的?

If i disabled Proguard and then Exported, the release apk file works fine now. So, some problem with Proguard?

我的文件夹结构

ProGuard的-project.txt

# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose

# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize
-dontpreverify
# Note that if you want to enable optimization, you cannot just
# include optimization flags in your own project configuration file;
# instead you will need to point to the
# "proguard-android-optimize.txt" file instead of this one from your
# project.properties file.

-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
-keep public class * extends android.app.Application
-keep public class * extends android.app.Activity
-keep public class * extends android.app.PreferenceActivity
-keep public class * extends android.view.View
-keep public class * extends android.widget.BaseAdapter
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * implements android.view.View.OnTouchListener
-keep public class * implements android.view.View.OnClickListener
-keep public class * extends com.actionbarsherlock.app.SherlockActivity
-keep public class * extends com.actionbarsherlock.app.SherlockFragmentActivity
-keep public class * extends com.actionbarsherlock.app.SherlockMapActivity
-keep public class * extends com.readystatesoftware.mapviewballoons.BalloonItemizedOverlay<OverlayItem>
-keep public class * extends com.actionbarsherlock.app.SherlockFragment


-libraryjars libs/android-support-v4.jar
-libraryjars libs/apache-mime4j-0.6.jar
-libraryjars libs/httpmime-4.0.1.jar
-libraryjars libs/libGoogleAnalyticsV2.jar  



-assumenosideeffects class android.util.Log {
    public static *** v(...);
    public static *** i(...);
    public static *** d(...);
    public static *** w(...);
    public static *** e(...);
}

# 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$* {
    public static <fields>;
}

# 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.
-dontwarn android.support.**
-dontwarn org.apache.**

我刚开始使用它的今天,我不知道如果我使用的正确方法。所以,请纠正我,如果我错了,任何地方。

I just started using it today, and i am not sure if i am using it the right way. So, please correct me if i am wrong anywhere.

这是LogCat中的错误:

01-02 13:18:54.711: E/AndroidRuntime(585): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xApp.app/com.xApp.app.LandingActivity}: java.lang.RuntimeException: java.lang.NoSuchMethodException: a(Activity,int)
01-02 13:18:54.711: E/AndroidRuntime(585):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
01-02 13:18:54.711: E/AndroidRuntime(585):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-02 13:18:54.711: E/AndroidRuntime(585):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-02 13:18:54.711: E/AndroidRuntime(585):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-02 13:18:54.711: E/AndroidRuntime(585):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-02 13:18:54.711: E/AndroidRuntime(585):  at android.os.Looper.loop(Looper.java:130)
01-02 13:18:54.711: E/AndroidRuntime(585):  at android.app.ActivityThread.main(ActivityThread.java:3683)
01-02 13:18:54.711: E/AndroidRuntime(585):  at java.lang.reflect.Method.invokeNative(Native Method)
01-02 13:18:54.711: E/AndroidRuntime(585):  at java.lang.reflect.Method.invoke(Method.java:507)
01-02 13:18:54.711: E/AndroidRuntime(585):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-02 13:18:54.711: E/AndroidRuntime(585):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-02 13:18:54.711: E/AndroidRuntime(585):  at dalvik.system.NativeStart.main(Native Method)
01-02 13:18:54.711: E/AndroidRuntime(585): Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: a(Activity,int)
01-02 13:18:54.711: E/AndroidRuntime(585):  at com.actionbarsherlock.a.a(Unknown Source)
01-02 13:18:54.711: E/AndroidRuntime(585):  at com.actionbarsherlock.app.SherlockActivity.a(Unknown Source)
01-02 13:18:54.711: E/AndroidRuntime(585):  at com.actionbarsherlock.app.SherlockActivity.setContentView(Unknown Source)
01-02 13:18:54.711: E/AndroidRuntime(585):  at com.xApp.app.LandingActivity.onCreate(Unknown Source)
01-02 13:18:54.711: E/AndroidRuntime(585):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-02 13:18:54.711: E/AndroidRuntime(585):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
01-02 13:18:54.711: E/AndroidRuntime(585):  ... 11 more
01-02 13:18:54.711: E/AndroidRuntime(585): Caused by: java.lang.NoSuchMethodException: a(Activity,int)
01-02 13:18:54.711: E/AndroidRuntime(585):  at java.lang.Class.getMatchingConstructor(Class.java:643)
01-02 13:18:54.711: E/AndroidRuntime(585):  at java.lang.Class.getConstructor(Class.java:472)
01-02 13:18:54.711: E/AndroidRuntime(585):  ... 17 more

感谢您

推荐答案

堆栈跟踪显示ActionBarSherlock未能找到一个构造函数一个(活动,INT)使用反射。它的文件确实规定ActionBarSherlock的每个分机都应该有这样一个构造函数。 ProGuard的不会(也不能)知道这一点,已取消的构造,因为它似乎不用在code。因此,你必须明确地告诉ProGuard的,以保持它的:

The stack trace shows that ActionBarSherlock is failing to find a constructor "a(Activity,int)" using reflection. Its documentation indeed specifies that each extension of ActionBarSherlock should have such a constructor. ProGuard doesn't (can't) know this and has removed the constructor, because it appears unused in the code. You therefore have to explicitly tell ProGuard to keep it:

-keepclassmembers class * extends com.actionbarsherlock.ActionBarSherlock {
    <init>(android.app.Activity, int);
}

在一般情况下,如果你在你的code或它的库与反思这样的堆栈跟踪,需要添加相应的配置。

In general, if you get such stack traces related to reflection in your code or its libraries, you need to add corresponding configuration.

这篇关于&QUOT;应用停止工作&QUOT;使Proguard的后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆