异常: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<com.shenyang.timescreensaver.MyApplication> is not accessible from java.lang.Class<android.app.AppComponentFactory>
        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<com.shenyang.timescreensaver.MyApplication> is not accessible from java.lang.Class<android.app.AppComponentFactory>
        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();
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值