Answer the question
In order to leave comments, you need to log in
I don’t understand what the error is, MainActivity and SecondActivity don’t start?
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.myapplication, PID: 22180
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang. NullPointerException: Attempt to invoke virtual method 'android.view.View android.widget.Button.findViewById(int)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3308)
at android.app.ActivityThread .handleLaunchActivity(ActivityThread.java:3457)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7562)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal. os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.widget.Button.findViewById(int)' on a null object reference
at com.example.myapplication.MainActivity.onCreate(MainActivity.java :18)
at android.app.Activity.performCreate(Activity.java:7893)
at android.app.Activity.performCreate(Activity.java:7880)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android .app.ActivityThread.performLaunchActivity(ActivityThread.java:3283)
Answer the question
In order to leave comments, you need to log in
Attempt to invoke virtual method 'android.view.View android.widget.Button.findViewById(int)' on a null object reference
setContentView(R.layout.activity_one_more);
l1.findViewById(R.id.level1);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question