我有这个包格式:
com example name oldAppname
现在,我通过Shift F6重构并重命名为:
com myCompanyname name newAppname
但是,现在当我运行我的应用程序时,我遇到了这个崩溃:
java.lang.classNotFoundException: DIDn't find class "com.example.name.oldAppname.Application" on path: DexPathList[[zip file "/data/app/com.myCompanyname.name.newAppname1/base.apk"],nativelibraryDirectorIEs=[/vendor/lib, /system/lib]]
我在newAppname下有我的Application.java,它在Manifest中正确定义
我尝试过的是:
>清洁和重建
>在build.gradle中更改applicationID
>清单中的包名称是正确的,应用程序和活动的所有名称也是正确的.
实际上,这是我的应用程序清单标记:
<application androID:name=".Application" ... >
甚至将.Application更改为完整的包名(com.blah.blah.Application)也行不通.
我错过了什么吗?有缺失的一步吗?
这是完整的日志:
java.lang.RuntimeException: Unable to instantiate application com.androID.tools.fd.runtime.bootstrapApplication: java.lang.IllegalStateException: java.lang.classNotFoundException: com.example.name.oldAppname.Application at androID.app.LoadedApk.makeApplication(LoadedApk.java:516) at androID.app.ActivityThread.handleBindApplication(ActivityThread.java:4345) at androID.app.ActivityThread.access00(ActivityThread.java:135) at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) at androID.os.Handler.dispatchMessage(Handler.java:102) at androID.os.Looper.loop(Looper.java:136) at androID.app.ActivityThread.main(ActivityThread.java:5045) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.IllegalStateException: java.lang.classNotFoundException: com.example.name.oldAppname.Application at com.androID.tools.fd.runtime.bootstrapApplication.createRealApplication(bootstrapApplication.java:220) at com.androID.tools.fd.runtime.bootstrapApplication.attachBaseContext(bootstrapApplication.java:239) at androID.app.Application.attach(Application.java:181) at androID.app.Instrumentation.newApplication(Instrumentation.java:1008) at androID.app.Instrumentation.newApplication(Instrumentation.java:992) at androID.app.LoadedApk.makeApplication(LoadedApk.java:511) at androID.app.ActivityThread.handleBindApplication(ActivityThread.java:4345) at androID.app.ActivityThread.access00(ActivityThread.java:135) at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) at androID.os.Handler.dispatchMessage(Handler.java:102) at androID.os.Looper.loop(Looper.java:136) at androID.app.ActivityThread.main(ActivityThread.java:5045) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.classNotFoundException: com.example.name.oldAppname.Application at java.lang.class.classForname(Native Method) at java.lang.class.forname(Class.java:251) at java.lang.class.forname(Class.java:216) at com.androID.tools.fd.runtime.bootstrapApplication.createRealApplication(bootstrapApplication.java:209) at com.androID.tools.fd.runtime.bootstrapApplication.attachBaseContext(bootstrapApplication.java:239) at androID.app.Application.attach(Application.java:181) at androID.app.Instrumentation.newApplication(Instrumentation.java:1008) at androID.app.Instrumentation.newApplication(Instrumentation.java:992) at androID.app.LoadedApk.makeApplication(LoadedApk.java:511) at androID.app.ActivityThread.handleBindApplication(ActivityThread.java:4345) at androID.app.ActivityThread.access00(ActivityThread.java:135) at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) at androID.os.Handler.dispatchMessage(Handler.java:102) at androID.os.Looper.loop(Looper.java:136) at androID.app.ActivityThread.main(ActivityThread.java:5045) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NoClassDefFoundError: com.example.name.oldAppname/Application at java.lang.class.classForname(Native Method) at java.lang.class.forname(Class.java:251) at java.lang.class.forname(Class.java:216) at com.androID.tools.fd.runtime.bootstrapApplication.createRealApplication(bootstrapApplication.java:209) at com.androID.tools.fd.runtime.bootstrapApplication.attachBaseContext(bootstrapApplication.java:239) at androID.app.Application.attach(Application.java:181) at androID.app.Instrumentation.newApplication(Instrumentation.java:1008) at androID.app.Instrumentation.newApplication(Instrumentation.java:992) at androID.app.LoadedApk.makeApplication(LoadedApk.java:511) at androID.app.ActivityThread.handleBindApplication(ActivityThread.java:4345) at androID.app.ActivityThread.access00(ActivityThread.java:135) at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) at androID.os.Handler.dispatchMessage(Handler.java:102) at androID.os.Looper.loop(Looper.java:136) at androID.app.ActivityThread.main(ActivityThread.java:5045) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.classNotFoundException: DIDn't find class "com.example.name.oldAppname.Application" on path: DexPathList[[zip file "/data/app/com.newCompanyname.name.newAppname-1.apk"],nativelibraryDirectorIEs=[/data/app-lib/com.myCompanyname.name.newAppname-1, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.classLoader.loadClass(ClassLoader.java:497) at java.lang.classLoader.loadClass(ClassLoader.java:457) at java.lang.class.classForname(Native Method) at java.lang.class.forname(Class.java:251) at java.lang.class.forname(Class.java:216) at com.androID.tools.fd.runtime.bootstrapApplication.createRealApplication(bootstrapApplication.java:209) at com.androID.tools.fd.runtime.bootstrapApplication.attachBaseContext(bootstrapApplication.java:239) at androID.app.Application.attach(Application.java:181) at androID.app.Instrumentation.newApplication(Instrumentation.java:1008) at androID.app.Instrumentation.newApplication(Instrumentation.java:992) at androID.app.LoadedApk.makeApplication(LoadedApk.java:511) at androID.app.ActivityThread.handleBindApplication(ActivityThread.java:4345) at androID.app.ActivityThread.access00(ActivityThread.java:135) at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) at androID.os.Handler.dispatchMessage(Handler.java:102) at androID.os.Looper.loop(Looper.java:136) at androID.app.ActivityThread.main(ActivityThread.java:5045) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method)
解决方法:
有时,禁用即时运行将解决问题.
或者,如果禁用“即时运行”不起作用,问题可能在于AndroID Studio尚未识别更改.首先备份您的项目,并注意您必须在此之后重新配置您的VCS(但不会丢失提交或分支,只需注册您的VCS.)
删除应用的.IDea和[yourProjectname] .iml.
对于未来的用户:
在AndroID Studio中重命名包的正确方法
>在“项目”窗格中,选择齿轮图标
>如果选中,则取消选中“Compact Empty MIDdle Packages”.
>现在继续使用重构 – >重命名每个分解的软件包名称(实际上是com,example,name,oldAppname)
>重命名可能会打开一个警告对话框,您可能需要在其中选择“重命名包”
>完成重命名包后,将gradle中的applicationID替换为正确的
>同步gradle
>清洁和重建
您可以找到更好的版本如何正确重构您的包here
P.S:您必须在未获得“ClassNotFound”异常的位置恢复原始包名称并尝试上述解决方案.
总结以上是内存溢出为你收集整理的android – 重构包名称使用ClassNotFoundException打破应用程序,因为找不到Application类,即使它在那里全部内容,希望文章能够帮你解决android – 重构包名称使用ClassNotFoundException打破应用程序,因为找不到Application类,即使它在那里所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)