安卓:无法实例化应用 [英] Android: Unable to instantiate application
问题描述
我改名为我的包,现在我得到这个奇怪的错误:
I renamed my package and now i get this strange error:
无法实例化应用app.MyApplication:抛出java.lang.ClassNotFoundException:app.MyApplication装载机dalvik.system.PathClassLoader
在所有MyApplication类是应用程序/应用程序。该清单说:
The MyApplication Class is in Application/app. The Manifest says:
<舱单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=应用程序
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="Application"
&lt;应用机器人:标签=AGG
机器人:名称=app.MyApplication......
<application android:label="AGG"
android:name="app.MyApplication"...
究竟什么是怎么回事?
What on Earth is going on?
我试着重新启动。清洁内置。是在一个模拟器,也不是真正的设备上dosnt工作。
I tried restart. Clean Built. Is dosnt work on an emulator nor on a real device.
任何帮助AP preciated ...
Any help appreciated...
推荐答案
让我们假设,你的项目基本包是真的应用程序
,因为你已经在说,它清单
。
Let's assume, that your projects base package is really Application
, as you've stated it in the manifest
.
如果你的所有MyApplication
类是这个包里面(类的包声明封装应用;
),然后在应用程序
元素的的AndroidManifest.xml
应为
If your MyApplication
class is inside this package (the package declaration of the class is package Application;
), then the application
element in your androidManifest.xml
should look like
<application android:name=".MyApplication" [...]
如果这个所有MyApplication
类是 Application.app里面
包(封装应用。应用;
),然后在清单中,你应该写:
If this MyApplication
class is inside the Application.app
package (package Application.app;
), then in the manifest you should write:
<application android:name=".app.MyApplication" [...]
如果你没有延长 android.app.Application
(你没有一个 MyApplication的延伸android.app.Application
类),只是想一个名字设置为你的应用程序,将其删除这个属性,因为它说的编译器,有一个应用程序
的扩展,应被实例化,而不是默认的 android.app.Application
。
If you didn't extend the android.app.Application
(you don't have a MyApplication extends android.app.Application
class), just wanted to set a name to your application, remove it this attribute, since it says to the compiler that there is an Application
extension that should be instantiated instead of the default android.app.Application
.
最后,如果第一个假设是错误的,你以任何理由在androidManifest的清单
元素的包声明,撤销,或更新您的类已经改变在该程序包。
And finally, if the first assumption is wrong, and you've changed for any reason the package declaration in your androidManifest's manifest
element, undo it or update your classes to be in that package.
这篇关于安卓:无法实例化应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!