带有静态上下文类的ClassNotFoundException

时间:2014-11-13 15:08:51

标签: java android eclipse classnotfoundexception android-context

当我使用eclipse在手机上运行我的应用程序时我完全没有问题,但是当我签署我的应用程序然后将其安装在我的设备上时,我得到了ClassNotFoundException。

android无法找到的类是一个扩展Application的静态上下文类:

public class ProjectContext extends Application{

    private static Context context;

    public void onCreate() {
        super.onCreate();
        ProjectContext.context = getApplicationContext();
    }

    public static Context getAppContext() {
        return ProjectContext.context;
    }
}

栈跟踪

java.lang.RuntimeException: Unable to instantiate application Context: java.lang.ClassNotFoundException: Didn't find class ".Context" on path: DexPathList[[zip file "/data/app/n-1.apk"],nativeLibraryDirectories=[/data/app-lib/app-1, /vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:514)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4446)
at android.app.ActivityThread.access$1500(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5146)
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:796)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "Context" on path: DexPathList[[zip file "/data/app/app-1.apk"],nativeLibraryDirectories=[/data/app-lib/app-1, /vendor/lib, /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 android.app.Instrumentation.newApplication(Instrumentation.java:975)
at android.app.LoadedApk.makeApplication(LoadedApk.java:509)
... 11 more

我不知道出了什么问题。我希望有人可以帮助我。

编辑:

private static SharedPreferences getData = PreferenceManager.getDefaultSharedPreferences(NzbManagerContext.getAppContext());

0 个答案:

没有答案