异常:java.lang.RuntimeException: Unable to instantiate application

2020-07-09 11:14:46.088 11648-11648/? E/timescreensave: Unknown bits set in runtime_flags: 0x8000
2020-07-09 11:14:46.200 11648-11648/? E/QarthLog: [PatchStore] current thread application info is null
2020-07-09 11:14:46.200 11648-11648/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.shenyang.timescreensaver, PID: 11648
    java.lang.RuntimeException: Unable to instantiate application com.shenyang.timescreensaver.MyApplication: java.lang.IllegalAccessException: java.lang.Class is not accessible from java.lang.Class
        at android.app.LoadedApk.makeApplication(LoadedApk.java:1304)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7320)
        at android.app.ActivityThread.access$2400(ActivityThread.java:308)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2295)
        at android.os.Handler.dispatchMessage(Handler.java:110)
        at android.os.Looper.loop(Looper.java:219)
        at android.app.ActivityThread.main(ActivityThread.java:8347)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
     Caused by: java.lang.IllegalAccessException: java.lang.Class is not accessible from java.lang.Class
        at java.lang.Class.newInstance(Native Method)
        at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
        at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:52)
        at android.app.Instrumentation.newApplication(Instrumentation.java:1167)
        at android.app.LoadedApk.makeApplication(LoadedApk.java:1296)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7320) 
        at android.app.ActivityThread.access$2400(ActivityThread.java:308) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2295) 
        at android.os.Handler.dispatchMessage(Handler.java:110) 
        at android.os.Looper.loop(Looper.java:219) 
        at android.app.ActivityThread.main(ActivityThread.java:8347) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055) 

你的类前面是不是没写public???

class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
    }
}

解决:补上public试试呢??

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
    }
}

你可能感兴趣的:(异常:java.lang.RuntimeException: Unable to instantiate application)