3

我有这个崩溃说我的应用程序类不存在,虽然它在那里。另外,这条线是什么"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());
        }
    }
}

任何想法?

谢谢!

4

1 回答 1

0

在您的AndroidManifest.xml

android:name="com.package.app.Application"

如果您有自己的扩展实现,请仅命名您的应用程序com.package.app.Application

和:

有时 eclipse/android-studio 会出现问题,请确保您尝试过 clean+build。

于 2013-09-12T03:48:48.807 回答