应用类在Android中没有发现使用ProGuard后 [英] Application class not found in Android after using ProGuard

查看:243
本文介绍了应用类在Android中没有发现使用ProGuard后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序运作良好,没有任何错误,这么远。但最近我使用ProGuard现在混淆code开始我看到在谷歌Play开发者控制台下面的错误报告:

My application worked well, without any errors, so far. But lately I've began using ProGuard to obfuscate the code now I see the following error report in the Google Play developer console:

java.lang.RuntimeException: Unable to instantiate application MYPACKAGE.MyApp: java.lang.ClassNotFoundException: MYPACKAGE.MyApp
at android.app.LoadedApk.makeApplication(LoadedApk.java:482)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3950)
at android.app.ActivityThread.access$1300(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1197)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4507)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: MYPACKAGE.MyApp
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newApplication(Instrumentation.java:945)
at android.app.LoadedApk.makeApplication(LoadedApk.java:477)

MyApp的是自定义应用程序类,很明显。只有一个在这个问题上的错误报告,到目前为止,虽然有10000活跃的安装。这是否意味着我不应该用那样的问题打扰或可以成为一个严​​重的问题?我怎样才能解决这个问题?

MyApp is the custom application class, obviously. There's only one error report on that issue so far, although there are 10,000+ active installations. Does that mean I shouldn't bother with that problem or could it be a serious issue? How can I resolve this?

推荐答案

尝试添加此行:

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application

proguard.cfg 文件

这篇关于应用类在Android中没有发现使用ProGuard后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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