Android:dalvik.system.BaseDexClassLoader.findClass中的java.lang.ClassNotFoundException

时间:2013-09-12 03:46:38

标签: android eclipse classnotfoundexception

我遇到了这个崩溃,说我的Application类不存在,尽管它存在。此外,这一行"Didn't find class "com.package.app.CustomApplication" on path: /mnt/asec/com.package.app-1/pkg.apk"的含义是什么?

这是完整的崩溃日志。

java.lang.RuntimeException: Unable to instantiate application com.package.app.CustomApplication: java.lang.ClassNotFoundException: Didn't find class "com.package.app.CustomApplication" on path: /mnt/asec/com.package.app-1/pkg.apk
at android.app.LoadedApk.makeApplication(LoadedApk.java:503)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4405)
at android.app.ActivityThread.access$1400(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1327)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5059)
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:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.package.app.CustomApplication" on path: /mnt/asec/com.package.app-1/pkg.apk
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:967)
at android.app.LoadedApk.makeApplication(LoadedApk.java:498)

另外,这是我的AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.package.app"
    android:versionCode="1"
    android:versionName="1.0"
    android:installLocation="preferExternal">

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="17" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="com.android.vending.BILLING" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
    <uses-permission android:name="android.permission.GET_ACCOUNTS"/>

    <supports-screens android:largeScreens="true"
                      android:xlargeScreens="true"/>

    <application
        android:name="com.package.app.CustomApplication"
        android:allowBackup="true"
        android:icon="@drawable/app_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" android:largeHeap="true">
        <activity
            android:name="com.package.app.MainActivity"
            android:alwaysRetainTaskState="true"
            android:noHistory="false"
            android:label="@string/app_name"
            android:configChanges="orientation|keyboardHidden"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

这是我的CustomApplication课程:

public class CustomApplication extends Application {

    private GameHandler gameHandler;
    public GameHandler getGameHandler() {
        if(gameHandler == null){
            initGameHandler();
        }
        return gameHandler;
    }

    public void setGameHandler(GameHandler gameHandler) {
        this.gameHandler = gameHandler;
    }

    @Override
    public void onCreate() {

    }

    public void initGameHandler()
    {
        if(this.gameHandler == null){
            this.gameHandler = new GameHandler(getApplicationContext());
        }
    }
}

有什么想法吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

AndroidManifest.xml

中删除此行
android:name="com.package.app.Application"

如果您有自己的实施扩展com.package.app.Application,请仅为您的应用命名。

有时eclipse / android-studio会出现打嗝,请确保您尝试了清洁+构建。