应用程序正在运行,但现在意外关闭

时间:2019-01-22 07:06:51

标签: java android

昨天我的应用view -> someMethod()正常运行。但是今天,当我在AVD中打开它时,它意外关闭。我在Log Cat中检查了错误日志,但对我来说似乎有些困惑。

我检查了duplicate question here,但其中包含由shopapp引起的错误日志。

错误日志:

findViewById

MainActivity:

--------- beginning of crash
    2019-01-22 12:21:52.836 4855-4855/com.local.xspac.shopapp E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.local.xspac.shopapp, PID: 4855
        java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.local.xspac.shopapp/com.local.xspac.shopapp.MainActivity}: java.lang.InstantiationException: java.lang.Class<com.local.xspac.shopapp.MainActivity> cannot be instantiated
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2567)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
            at android.app.ActivityThread.-wrap12(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:154)
            at android.app.ActivityThread.main(ActivityThread.java:6119)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
         Caused by: java.lang.InstantiationException: java.lang.Class<com.local.xspac.shopapp.MainActivity> cannot be instantiated
            at java.lang.Class.newInstance(Native Method)
            at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2557)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) 
            at android.app.ActivityThread.-wrap12(ActivityThread.java) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) 
            at android.os.Handler.dispatchMessage(Handler.java:102) 
            at android.os.Looper.loop(Looper.java:154) 
            at android.app.ActivityThread.main(ActivityThread.java:6119) 
            at java.lang.reflect.Method.invoke(Native Method) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

1 个答案:

答案 0 :(得分:2)

  

java.lang.RuntimeException:无法实例化活动   ComponentInfo

不要

public abstract class MainActivity extends AppCompatActivity {

要做

public class MainActivity extends AppCompatActivity {