If you press Android RUN APP, it will be forced to end as soon as the app startsㅠ<
It pops up like this, but I don't know what I did wrong.
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.myapplication_screen1, PID: 2389 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication_screen1/com.example.myapplication_screen1.ConfigActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6944) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference at com.example.myapplication_screen1.ConfigActivity.onCreate(ConfigActivity.java:26) at android.app.Activity.performCreate(Activity.java:7183) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6944) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
android-studio
It seems that you are using Button
, and NullPointerException
occurred when you called setOnClickListener()
. Check if Button object is null or not. If you can attach the code, I can give you more detailed advice.
Unable to start activity Looking at the error message, isn't there a typo in the manifest or you didn't register the starting activity? Place manifest sauce on top, or place sauce on top of the starting activity.
© 2024 OneMinuteCode. All rights reserved.