Android Emulator Stops working

+1 James henter · January 14, 2016
I'm trying to test my app in Android Emulator, but for some reason every time I load my app it suddenly crashes. 

Error Logs: 
01-13 18:24:51.244 4486-4486/? I/art: Not late-enabling -Xcheck:jni (already on)
01-13 18:24:51.328 4486-4494/? I/art: Debugger is no longer active
01-13 18:24:51.369 4486-4494/? W/art: Suspending all threads took: 41.636ms
01-13 18:24:51.373 4486-4486/? W/System: ClassLoader referenced unknown path: /data/app/com.example.apps.newapplication-2/lib/x86
01-13 18:24:51.423 4486-4486/? D/AndroidRuntime: Shutting down VM
01-13 18:24:51.424 4486-4486/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                 Process: com.example.apps.newapplication, PID: 4486
                                                 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.apps.newapplication/com.example.apps.newapplication.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.support.v7.widget.Toolbar.getTitle()' on a null object reference
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                     at android.os.Looper.loop(Looper.java:148)
                                                     at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.support.v7.widget.Toolbar.getTitle()' on a null object reference
                                                     at android.support.v7.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:98)
                                                     at android.support.v7.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:91)
                                                     at android.support.v7.app.ToolbarActionBar.<init>(ToolbarActionBar.java:73)
                                                     at android.support.v7.app.AppCompatDelegateImplV7.setSupportActionBar(AppCompatDelegateImplV7.java:205)
                                                     at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:99)
                                                     at com.example.apps.newapplication.MainActivity.onCreate(MainActivity.java:28)
                                                     at android.app.Activity.performCreate(Activity.java:6237)
                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                     at android.os.Looper.loop(Looper.java:148) 
                                                     at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
01-13 18:25:03.649 4486-4494/com.example.apps.newapplication W/art: Suspending all threads took: 60.192ms
01-13 18:25:22.653 4486-4494/com.example.apps.newapplication W/art: Suspending all threads took: 44.409ms
01-13 18:25:29.152 4486-4494/com.example.apps.newapplication W/art: Suspending all threads took: 24.137ms

 

Post a Reply

Replies

Oldest  Newest  Rating
0 Gary Whitney · January 14, 2016
I see the source of the problem is line 28 in your mainActivity.
I also see that you are trying to get the name of the toolbar but apparently your reference to the toolbar is null.

Maybe you need to use Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
or
Maybe you don't have the right library for the activity your are extending.
0 James henter · January 15, 2016
@Garey Whitney Thank for your reply. I will check it out.
  • 1

Java / Android Development

129,757 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator