Android应用程序ClassNotFoundException异常,无法实例化应用 [英] Android Application ClassNotFoundException, Unable to instantiate application

查看:1660
本文介绍了Android应用程序ClassNotFoundException异常,无法实例化应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这异常报告10 /周,我试图找到解决办法,但失败了。我有点失望,这种异常,并找遍了所有相关的帖子。 (PS我注意到,全名(安卓名=com.example.AcraApplication)抛出更多的异常比短一(机器人:名称=。AcraApplication))

This exception is reported 10/week, I tried to find solution but failed. I'm a little frustrated with this sort of exception, and searched all related posts. (P.S. I noticed that full name (android:name="com.example.AcraApplication") throw more exceptions than short one(android:name=".AcraApplication").)

public class AcraApplication extends Application {
public void onCreate() {
        ACRA.init(this);
        super.onCreate();
    }


<application
        android:name=".AcraApplication"
        android:icon="@drawable/app_icon"
        android:label="@string/app_name" >


java.lang.RuntimeException: Unable to instantiate application com.example.AcraApplication: java.lang.ClassNotFoundException: Didn't find class "com.example.AcraApplication" on path: DexPathList[[zip file "/mnt/asec/com.example-2/pkg.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4554)
at android.app.ActivityThread.access$1600(ActivityThread.java:161)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1325)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5356)
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:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.AcraApplication" on path: DexPathList[[zip file "/mnt/asec/com.example-2/pkg.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.Instrumentation.newApplication(Instrumentation.java:993)
at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
... 11 more
Suppressed: java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:296)
at dalvik.system.DexFile.<init>(DexFile.java:80)
at dalvik.system.DexFile.<init>(DexFile.java:59)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:263)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:230)
at dalvik.system.DexPathList.<init>(DexPathList.java:112)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:58)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:65)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:57)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:326)
at android.app.LoadedApk.makeApplication(LoadedApk.java:508)
... 11 more

编辑:我注意到,当我重新安装和放大器;打开使用CTRL + F11在日食不点击它的图标,它更频繁地发生

I noticed that when I reinstall&open using ctrl+F11 in eclipse without clicking its icon, it occurs more frequently.

推荐答案

你有没有在你的类文件的顶部声明的包名?

Have you declared the package name at the top of your class files?

它应该有一个包裹在像这样每个类文件的顶部声明:

It should have a package declared at the top of each class file like so:

package com.example;

import ...

public class AcraApplication extends Application {
    ...
}

所有的与包声明你的类文件应该是在同一个目录,的src / COM /例子

您还必须声明你的包你的的Andr​​oidManifest.xml 文件以及所有子类为&LT;活动... /&GT;

You must also declare your package in your AndroidManifest.xml file as well as all subclasses as <activity ... />

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example"
    ... >

    <application
        ... >
        <activity
            android:name=".AcraApplication"
            ... >
        </activity>
    </application>
</manifest>

这篇关于Android应用程序ClassNotFoundException异常,无法实例化应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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