For some reason when i put the line setSupportActionBar(MyToolBarVariable)... It goes on to my Genymotion Emulator.. But when it opens the app, it says :
Unfourtuanetly "AppName" has Stoped
But if i delete the setSupportActionBar() Everything works fine... Whats the problem here.. Im going to post MainActivity.java file.. If you need to see others please tell me so below. Thanks for helping!
package com.example.amanuel.zoo4;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
setContentView(R.layout.activity_main);
}
}
Here is the LOGCAT When i press the app in my emulator!
04-06 02:09:02.522 652-1011/? I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.amanuel.zoo4/.MainActivity (has extras)} from uid 10008 on display 0
04-06 02:09:02.721 3360-3360/? I/art: Late-enabling -Xcheck:jni
04-06 02:09:02.762 652-1021/? I/ActivityManager: Start proc 3360:com.example.amanuel.zoo4/u0a63 for activity com.example.amanuel.zoo4/.MainActivity
04-06 02:09:02.815 652-667/? W/art: Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.activityPaused(android.os.IBinder) from ActivityManagerService.java:6439 waiters=1 for 136ms
04-06 02:09:02.978 3360-3360/? W/System: ClassLoader referenced unknown path: /data/app/com.example.amanuel.zoo4-2/lib/x86
04-06 02:09:03.170 3360-3360/? D/AndroidRuntime: Shutting down VM
04-06 02:09:03.178 3360-3360/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.amanuel.zoo4, PID: 3360
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.amanuel.zoo4/com.example.amanuel.zoo4.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.internal.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:94)
at android.support.v7.internal.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:87)
at android.support.v7.internal.app.ToolbarActionBar.<init>(ToolbarActionBar.java:77)
at android.support.v7.app.AppCompatDelegateImplV7.setSupportActionBar(AppCompatDelegateImplV7.java:198)
at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:96)
at com.example.amanuel.zoo4.MainActivity.onCreate(MainActivity.java:13)
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)
04-06 02:09:03.193 652-1021/? W/ActivityManager: Force finishing activity com.example.amanuel.zoo4/.MainActivity
04-06 02:09:03.500 652-1021/? I/WindowManager: Screenshot max retries 4 of Token{75d8954 ActivityRecord{722f0a7 u0 com.example.amanuel.zoo4/.MainActivity t42 f}} appWin=Window{450aeec u0 Starting com.example.amanuel.zoo4} drawState=1
04-06 02:09:03.514 652-652/? W/art: Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.crashApplication(com.android.server.am.ProcessRecord, android.app.ApplicationErrorReport$CrashInfo) from ActivityManagerService.java:12502 waiters=0 for 299ms
04-06 02:09:03.639 652-666/? W/art: Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.crashApplication(com.android.server.am.ProcessRecord, android.app.ApplicationErrorReport$CrashInfo) from ActivityManagerService.java:12502 waiters=1 for 216ms
04-06 02:09:03.640 652-652/? W/art: Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService$UiHandler.handleMessage(android.os.Message) from ActivityManagerService.java:1397 waiters=1 for 111ms
04-06 02:09:03.814 652-1641/? I/OpenGLRenderer: Initialized EGL, version 1.4
04-06 02:09:04.021 652-666/? W/ActivityManager: Activity pause timeout for ActivityRecord{722f0a7 u0 com.example.amanuel.zoo4/.MainActivity t42 f}
04-06 02:09:04.129 652-1641/? W/EGL_emulation: eglSurfaceAttrib not implemented
04-06 02:09:04.130 652-1641/? W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xd60610a0, error=EGL_SUCCESS
04-06 02:09:04.198 652-667/? I/Choreographer: Skipped 32 frames! The application may be doing too much work on its main thread.
04-06 02:09:04.303 652-981/? I/ActivityManager: Killing 1792:com.android.keychain/1000 (adj 15): empty for 3078s
04-06 02:09:04.763 652-668/? E/BluetoothAdapter: Bluetooth binder is null
04-06 02:09:04.825 652-667/? I/Choreographer: Skipped 37 frames! The application may be doing too much work on its main thread.
04-06 02:09:07.697 3360-3360/? I/Process: Sending signal. PID: 3360 SIG: 9
04-06 02:09:07.732 652-679/? I/ActivityManager: Process com.example.amanuel.zoo4 (pid 3360) has died
04-06 02:09:07.771 652-1641/? E/Surface: getSlotFromBufferLocked: unknown buffer: 0xde8f0df0
04-06 02:09:07.844 652-1641/? D/OpenGLRenderer: endAllStagingAnimators on 0xda3b2380 (RippleDrawable) with handle 0xdc57f670
04-06 02:09:07.852 652-652/? W/art: Long monitor contention event with owner method=void android.view.WindowManagerGlobal.removeView(android.view.View, boolean) from WindowManagerGlobal.java:349 waiters=0 for 102ms
04-06 02:09:07.854 652-1164/? W/InputMethodManagerService: Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#bc8dc8f attribute=null, token = android.os.BinderProxy#4b639cb
04-06 02:09:08.200 652-671/? W/AppOps: Finishing op nesting under-run: uid 1000 pkg android code 24 time=0 duration=0 nesting=0
04-06 02:09:12.630 308-647/? W/AudioFlinger: write blocked for 9842 msecs, 14 delayed writes, thread 0xf1e00000
04-06 02:09:18.081 100-100/? D/Genyd: Received Set Clipboard
04-06 02:09:18.081 100-100/? D/Genymotion: Received Set Clipboard
Try putting setContentView(R.layout.activity_main); before trying to instantiate the Toolbar.
Related
I am making app which on portrait mode shows fragmentA (containing Listview) and when in Landscape mode, it shows fragmentA and fragmentB(Listview and its corresponding description).It keeps on crashing,my hunch says either there is a fault in if-else condition in MainActivity or problem is in communication pattern.I request Everyone to please Help. Here is my MainActivity.xml
package com.example.prince.fragment_modularui2;
import android.content.Intent;
import android.content.res.Resources;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity implements FragmentA.Communicator{
String s;
Resources r=getResources();
String[] a=r.getStringArray(R.array.descr);
FragmentA fa;
FragmentB fb;
FragmentManager manager;
#Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
manager=getSupportFragmentManager();
//fa always present
fa= (FragmentA) manager.findFragmentById(R.id.fragment);
fb= (FragmentB) manager.findFragmentById(R.id.fragment2);
fa.setCommunicator(this);
}
#Override
public void respond(int data) {
Intent i=new Intent(this,AnotherActivity.class);
i.putExtra("index",data);
startActivity(i);
}
}
here is activity_main.xml in Portrait
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.example.prince.fragment_modularui2.FragmentA"
android:id="#+id/fragment"
></fragment>
</LinearLayout>
activity_main in landscape
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<fragment
android:id="#+id/fragment"
android:name="com.example.prince.fragment_modularui2.FragmentA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true" />
<fragment
android:id="#+id/fragment2"
android:name="com.example.prince.fragment_modularui2.FragmentB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true" />
</LinearLayout>
Rest of the code is https://github.com/AlmightyHeathcliff/Fragment_ModularUi2
The stackTrace is
07-18 09:45:09.252 1974-1974/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
07-18 09:45:09.254 1974-1974/? D/AndroidRuntime: CheckJNI is OFF
07-18 09:45:09.289 1974-1974/? W/art: Unexpected CPU variant for X86 using defaults: x86
07-18 09:45:09.301 1974-1974/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
07-18 09:45:09.316 1974-1974/? E/memtrack: Couldn't load memtrack module (No such file or directory)
07-18 09:45:09.316 1974-1974/? E/android.os.Debug: failed to load memtrack module: -2
07-18 09:45:09.317 1974-1974/? I/Radio-JNI: register_android_hardware_Radio DONE
07-18 09:45:09.325 1974-1974/? D/AndroidRuntime: Calling main entry com.android.commands.pm.Pm
07-18 09:45:09.330 1974-1974/? I/art: System.exit called, status: 0
07-18 09:45:09.330 1974-1974/? I/AndroidRuntime: VM exiting with result code 0.
07-18 09:45:09.333 1974-1982/? W/MessageQueue: Handler (android.os.Handler) {f6bbfb3} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (android.os.Handler) {f6bbfb3} sending message to a Handler on a dead thread
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
at android.os.Handler.enqueueMessage(Handler.java:643)
at android.os.Handler.sendMessageAtTime(Handler.java:612)
at android.os.Handler.sendMessageDelayed(Handler.java:582)
at android.os.Handler.post(Handler.java:338)
at android.os.ResultReceiver$MyResultReceiver.send(ResultReceiver.java:57)
at com.android.internal.os.IResultReceiver$Stub.onTransact(IResultReceiver.java:58)
at android.os.Binder.execTransact(Binder.java:565)
07-18 09:45:09.972 1993-1993/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
07-18 09:45:09.976 1993-1993/? D/AndroidRuntime: CheckJNI is OFF
07-18 09:45:10.012 1993-1993/? W/art: Unexpected CPU variant for X86 using defaults: x86
07-18 09:45:10.015 1993-1993/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
07-18 09:45:10.049 1993-1993/? E/memtrack: Couldn't load memtrack module (No such file or directory)
07-18 09:45:10.049 1993-1993/? E/android.os.Debug: failed to load memtrack module: -2
07-18 09:45:10.050 1993-1993/? I/Radio-JNI: register_android_hardware_Radio DONE
07-18 09:45:10.059 1993-1993/? D/AndroidRuntime: Calling main entry com.android.commands.pm.Pm
07-18 09:45:10.064 1993-2001/? W/MessageQueue: Handler (android.os.Handler) {f6bbfb3} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (android.os.Handler) {f6bbfb3} sending message to a Handler on a dead thread
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
at android.os.Handler.enqueueMessage(Handler.java:643)
at android.os.Handler.sendMessageAtTime(Handler.java:612)
at android.os.Handler.sendMessageDelayed(Handler.java:582)
at android.os.Handler.post(Handler.java:338)
at android.os.ResultReceiver$MyResultReceiver.send(ResultReceiver.java:57)
at com.android.internal.os.IResultReceiver$Stub.onTransact(IResultReceiver.java:58)
at android.os.Binder.execTransact(Binder.java:565)
07-18 09:45:10.064 1993-1993/? I/art: System.exit called, status: 0
07-18 09:45:10.064 1993-1993/? I/AndroidRuntime: VM exiting with result code 0.
07-18 09:45:13.487 2005-2005/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
07-18 09:45:13.491 2005-2005/? D/AndroidRuntime: CheckJNI is OFF
07-18 09:45:13.569 2005-2005/? W/art: Unexpected CPU variant for X86 using defaults: x86
07-18 09:45:13.575 2005-2005/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
07-18 09:45:13.708 2009-2009/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
07-18 09:45:13.715 2009-2009/? D/AndroidRuntime: CheckJNI is OFF
07-18 09:45:13.760 2005-2005/? E/memtrack: Couldn't load memtrack module (No such file or directory)
07-18 09:45:13.760 2005-2005/? E/android.os.Debug: failed to load memtrack module: -2
07-18 09:45:13.761 2005-2005/? I/Radio-JNI: register_android_hardware_Radio DONE
07-18 09:45:13.776 2005-2005/? D/AndroidRuntime: Calling main entry com.android.commands.wm.Wm
07-18 09:45:13.814 2009-2009/? W/art: Unexpected CPU variant for X86 using defaults: x86
07-18 09:45:13.825 2009-2009/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
07-18 09:45:13.833 2005-2005/? D/AndroidRuntime: Shutting down VM
07-18 09:45:13.839 2005-2019/? W/art: Thread attaching while runtime is shutting down: Binder:2005_2
07-18 09:45:13.839 2005-2019/? I/AndroidRuntime: NOTE: attach of thread 'Binder:2005_2' failed
07-18 09:45:13.891 2009-2009/? E/memtrack: Couldn't load memtrack module (No such file or directory)
07-18 09:45:13.891 2009-2009/? E/android.os.Debug: failed to load memtrack module: -2
07-18 09:45:13.892 2009-2009/? I/Radio-JNI: register_android_hardware_Radio DONE
07-18 09:45:13.903 2009-2009/? D/AndroidRuntime: Calling main entry com.android.commands.am.Am
07-18 09:45:13.909 765-1149/system_process I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.prince.fragment_modularui2/.MainActivity} from uid 0 on display 0
07-18 09:45:13.919 2009-2009/? D/AndroidRuntime: Shutting down VM
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: returned from zygote!
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: done updating battery stats
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: building log message
07-18 09:45:13.993 765-1021/system_process I/ActivityManager: Start proc 2027:com.example.prince.fragment_modularui2/u0a115 for activity com.example.prince.fragment_modularui2/.MainActivity
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: starting to update pids map
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: done updating pids map
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: done starting proc!
07-18 09:45:14.003 2027-2027/? I/art: Late-enabling -Xcheck:jni
07-18 09:45:14.004 2027-2027/? W/art: Unexpected CPU variant for X86 using defaults: x86
07-18 09:45:14.258 500-757/? D/gralloc_vbox86: gralloc_alloc: format 1 and usage 0x933 imply creation of host color buffer
07-18 09:45:14.784 2027-2027/com.example.prince.fragment_modularui2 W/System: ClassLoader referenced unknown path: /data/app/com.example.prince.fragment_modularui2-1/lib/x86
07-18 09:45:14.813 2027-2027/com.example.prince.fragment_modularui2 I/InstantRun: starting instant run server: is main process
07-18 09:45:14.814 2027-2027/com.example.prince.fragment_modularui2 V/InstantRun: Starting server socket listening for package com.example.prince.fragment_modularui2 on android.net.LocalSocketAddress#8989009
07-18 09:45:14.814 2027-2027/com.example.prince.fragment_modularui2 V/InstantRun: Started server for package com.example.prince.fragment_modularui2
07-18 09:45:14.903 2027-2027/com.example.prince.fragment_modularui2 D/AndroidRuntime: Shutting down VM
07-18 09:45:14.904 2027-2027/com.example.prince.fragment_modularui2 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.prince.fragment_modularui2, PID: 2027
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.prince.fragment_modularui2/com.example.prince.fragment_modularui2.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
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.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
at android.content.ContextWrapper.getResources(ContextWrapper.java:86)
at android.view.ContextThemeWrapper.getResourcesInternal(ContextThemeWrapper.java:127)
at android.view.ContextThemeWrapper.getResources(ContextThemeWrapper.java:121)
at android.support.v7.app.AppCompatActivity.getResources(AppCompatActivity.java:549)
at com.example.prince.fragment_modularui2.MainActivity.<init>(MainActivity.java:12)
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)
07-18 09:45:14.907 765-1021/system_process W/ActivityManager: Force finishing activity com.example.prince.fragment_modularui2/.MainActivity
07-18 09:45:15.031 500-505/? D/gralloc_vbox86: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
07-18 09:45:15.058 500-505/? D/gralloc_vbox86: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
07-18 09:45:15.115 500-505/? D/gralloc_vbox86: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
07-18 09:45:15.232 765-1842/system_process I/OpenGLRenderer: Initialized EGL, version 1.4
07-18 09:45:15.232 765-1842/system_process D/OpenGLRenderer: Swap behavior 1
07-18 09:45:15.429 765-779/system_process W/ActivityManager: Activity pause timeout for ActivityRecord{b0310c2 u0 com.example.prince.fragment_modularui2/.MainActivity t693 f}
07-18 09:45:15.431 765-779/system_process I/ActivityManager: Killing 1353:android.process.media/u0a10 (adj 906): empty #17
07-18 09:45:15.432 765-779/system_process I/WindowManager: Failed to capture screenshot of Token{7756ed3 ActivityRecord{b0310c2 u0 com.example.prince.fragment_modularui2/.MainActivity t693 f}} appWin=Window{7f1e54b u0 Starting com.example.prince.fragment_modularui2} drawState=1
07-18 09:45:15.448 765-786/system_process I/Choreographer: Skipped 70 frames! The application may be doing too much work on its main thread.
07-18 09:45:15.452 765-1150/system_process D/ActivityManager: cleanUpApplicationRecord -- 1353
07-18 09:45:15.456 765-1842/system_process E/EGL_emulation: tid 1842: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
07-18 09:45:15.456 765-1842/system_process W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xc4afa800, error=EGL_BAD_MATCH
07-18 09:45:16.337 765-780/system_process I/Choreographer: Skipped 52 frames! The application may be doing too much work on its main thread.
07-18 09:45:25.438 765-779/system_process W/ActivityManager: Activity destroy timeout for ActivityRecord{b0310c2 u0 com.example.prince.fragment_modularui2/.MainActivity t693 f}
From the stacktrace I gather that you are calling getResources() on a Context that is null. This makes sense because you are declaring your resources as a field like:
Resources res = getResources();
This gets executed before the activity is created but you can only call getResources() once the activity is created. So the solution is to declare your resources like:
private Resources res;
And in your activity onCreate method you do:
res = getResources();
This also means that you can't use the res variable until the onCreate method is executed. Generally it is better to not declare resources as a variable like that but rather declare your string array as:
String[] a;
and then in onCreate just call: a = getResources().getStringArray(R.array.desc);
One other tip I can give you is to name your variable clearer. A string array named 'a' is not very descriptive. You can call it something like descriptionArray to make it more clear.
I/art: Background sticky concurrent mark sweep GC freed 2534(750KB) AllocSpace objects, 2(32KB) LOS objects, 16% free, 1439KB/1723KB, paused 1.210ms total 209.320ms
W/art: Suspending all threads took: 48.938ms
W/MainActivity: onResume
W/art: Suspending all threads took: 33.435ms
I/art: Background partial concurrent mark sweep GC freed 1004(119KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 1448KB/2MB, paused 33.859ms total 111.039ms
D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
[ 09-02 18:38:14.477 2286: 2286 D/ ]
HostConnection::get() New Host Connection established 0x7f5d1785eac0, tid 2286
D/Atlas: Validating map...
E/AndroidRuntime: FATAL EXCEPTION: IntentService[]
Process: com.example.user.gcmexample, PID: 2286
java.lang.IncompatibleClassChangeError: The method 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' was expected to be of type virtual but instead was found to be of type direct (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar)
at com.google.android.gms.iid.zzd.zzdL(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
at com.example.user.gcmexample.GCMRegistrationIntentService.registerGCM(GCMRegistrationIntentService.java:31)
at com.example.user.gcmexample.GCMRegistrationIntentService.onHandleIntent(GCMRegistrationIntentService.java:24)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Enabling debug mode 0
W/EGL_emulation: eglSurfaceAttrib not implemented
W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7f5d1a94d200, error=EGL_SUCCESS
W/MainActivity: onPause
I/Process: Sending signal. PID: 2286 SIG: 9
Application terminated.
I am working on google cloud messaging with Android. When I am running program, my app not launching and giving error message
Unfortunately "Application name " has stopped.
I've created an application in React Native that works fine in iOS. I've copied the code over to the Android portion of it, and separated out the platform-specific components. When I hit a certain component, the app crashes with an "Unfortunately has stopped".
There are no logs, no error in the console, nothing. What do I look for and where can I look? Logs? Somewhere in code?
In ~/genymotion-log/Google Nexus 6<...>-logcat.txt, I see the following:
05-15 23:50:14.379 D/OpenGLRenderer( 620): Use EGL_SWAP_BEHAVIOR_PRESERVED: true
05-15 23:50:14.380 D/Atlas ( 620): Validating map...
05-15 23:50:14.429 I/OpenGLRenderer( 620): Initialized EGL, version 1.4
05-15 23:50:14.429 D/ ( 620): HostConnection::get() New Host Connection established 0xaf31ca40, tid 1876
05-15 23:50:14.463 D/OpenGLRenderer( 620): Enabling debug mode 0
05-15 23:50:14.489 W/EGL_emulation( 620): eglSurfaceAttrib not implemented
05-15 23:50:14.490 W/OpenGLRenderer( 620): Failed to set EGL_SWAP_BEHAVIOR on surface 0x9e45dfc0, error=EGL_SUCCESS
05-15 23:50:14.490 W/EGL_emulation( 941): eglSurfaceAttrib not implemented
05-15 23:50:14.490 W/OpenGLRenderer( 941): Failed to set EGL_SWAP_BEHAVIOR on surface 0xb43e44a0, error=EGL_SUCCESS
05-15 23:50:14.952 I/ActivityManager( 620): Killing 1492:com.android.onetimeinitializer/u0a10 (adj 15): empty #17
05-15 23:50:15.219 W/OpenGLRenderer( 941): Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
05-15 23:50:15.440 W/ResourceType( 724): No package identifier when getting value for resource number 0x00000000
05-15 23:50:15.442 W/PackageManager( 724): Failure retrieving resources for com.bidsmart: Resource ID #0x0
05-15 23:50:18.400 W/AudioTrack( 620): AUDIO_OUTPUT_FLAG_FAST denied by client
05-15 23:50:18.424 I/Process ( 1805): Sending signal. PID: 1805 SIG: 9
05-15 23:50:18.463 D/OpenGLRenderer( 620): endAllStagingAnimators on 0xa1a6f780 (RippleDrawable) with handle 0xaf3be470
05-15 23:50:18.468 I/ActivityManager( 620): Process com.bidsmart (pid 1805) has died
05-15 23:50:18.472 W/InputMethodManagerService( 620): Got RemoteException sending setActive(false) notification to pid 1805 uid 10061
No fix, but the reason is I'm pushing too much data from the server to the client. Once I ran adb logcat, I got this:
java.lang.OutOfMemoryError: Failed to allocate a 2470012 byte allocation with 48508 free bytes and 47KB until OOM.
Turns out I'm pushing my images over and over to the client until it breaks. iOS can handle it but RN can't.
Link to StackOverflow related thread: Android:java.lang.OutOfMemoryError: Failed to allocate a 23970828 byte allocation with 2097152 free bytes and 2MB until OOM
I m a newbie to Android. I am trying to use google location API and when run in the emulator it shows Unfortunately your app stopped working.
I did a adb logcat and here is my stacktrace
10-31 23:43:02.010 2370 2370 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
10-31 23:43:02.011 2370 2370 D AndroidRuntime: CheckJNI is ON
10-31 23:43:02.026 2370 2370 I art : JIT created with code_cache_capacity=2MB compile_threshold=1000
10-31 23:43:02.030 2370 2370 D ICU : No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
10-31 23:43:02.044 2370 2370 E memtrack: Couldn't load memtrack module (No such file or directory)
10-31 23:43:02.044 2370 2370 E android.os.Debug: failed to load memtrack module: -2
10-31 23:43:02.045 2370 2370 I Radio-JNI: register_android_hardware_Radio DONE
10-31 23:43:02.062 2370 2370 D AndroidRuntime: Calling main entry com.android.commands.pm.Pm
10-31 23:43:02.073 2228 2240 I art : CollectorTransition marksweep + semispace GC freed 125(-7KB) AllocSpace objects, 0(0B) LOS objects, 57% free, 379KB/891KB, paused 5.591ms total 5.591ms
10-31 23:43:02.080 2228 2242 D DefContainer: Copying /data/local/tmp/HighwayMechanic.apk to base.apk
10-31 23:43:02.181 1138 1177 I PackageManager.DexOptimizer: Running dexopt (dex2oat) on: /data/app/vmdl931695514.tmp/base.apk pkg=com.highway.highwaymechanic isa=x86 vmSafeMode=false debuggable=true oatDir = /data/app/vmdl931695514.tmp/oat
10-31 23:43:02.190 2382 2382 W dex2oat : Unexpected CPU variant for X86 using defaults: x86
10-31 23:43:02.190 2382 2382 W dex2oat : Mismatch between dex2oat instruction set features (ISA: X86 Feature string: smp,-ssse3,-sse4.1,-sse4.2,-avx,-avx2) and those of dex2oat executable (ISA: X86 Feature string: smp,ssse3,-sse4.1,-sse4.2,-avx,-avx2) for the command line:
10-31 23:43:02.190 2382 2382 W dex2oat : /system/bin/dex2oat --zip-fd=6 --zip-location=base.apk --oat-fd=7 --oat-location=/data/app/vmdl931695514.tmp/oat/x86/base.odex --instruction-set=x86 --instruction-set-variant=x86 --instruction-set-features=default --runtime-arg -Xms64m --runtime-arg -Xmx512m --swap-fd=8 --debuggable
10-31 23:43:02.190 2382 2382 I dex2oat : /system/bin/dex2oat --debuggable
10-31 23:43:08.200 2382 2382 I dex2oat : dex2oat took 6.009s (threads: 1) arena alloc=2MB java alloc=6MB native alloc=32MB free=2MB
10-31 23:43:08.276 1138 1162 I ActivityManager: Force stopping com.highway.highwaymechanic appid=10053 user=-1: uninstall pkg
10-31 23:43:08.294 1138 1177 I PackageManager: Package com.highway.highwaymechanic codePath changed from /data/app/com.highway.highwaymechanic-2 to /data/app/com.highway.highwaymechanic-1; Retaining data and using new
10-31 23:43:08.295 1138 1162 I ActivityManager: Force stopping com.highway.highwaymechanic appid=10053 user=-1: replace pkg
10-31 23:43:08.296 1138 1177 W PackageManager: Code path for com.highway.highwaymechanic changing from /data/app/com.highway.highwaymechanic-2 to /data/app/com.highway.highwaymechanic-1
10-31 23:43:08.296 1138 1177 W PackageManager: Resource path for com.highway.highwaymechanic changing from /data/app/com.highway.highwaymechanic-2 to /data/app/com.highway.highwaymechanic-1
10-31 23:43:08.333 1138 1177 W Settings: Setting install_non_market_apps has moved from android.provider.Settings.Global to android.provider.Settings.Secure, returning read-only value.
10-31 23:43:08.333 1138 1177 I art : Starting a blocking GC Explicit
10-31 23:43:08.353 1138 1177 I art : Explicit concurrent mark sweep GC freed 10787(756KB) AllocSpace objects, 11(220KB) LOS objects, 19% free, 5MB/6MB, paused 517us total 13.651ms
10-31 23:43:08.357 1138 1177 W PackageManager: Couldn't remove dex file for package: at location /data/app/com.highway.highwaymechanic-2/base.apk, retcode=-1
10-31 23:43:08.359 1138 1177 I ActivityManager: Force stopping com.highway.highwaymechanic appid=10053 user=0: pkg removed
10-31 23:43:08.360 2370 2370 I art : System.exit called, status: 0
10-31 23:43:08.360 2370 2370 I AndroidRuntime: VM exiting with result code 0.
10-31 23:43:08.400 1138 1138 D JobSchedulerService: Receieved: android.intent.action.PACKAGE_REMOVED
10-31 23:43:08.403 1566 1566 D CarrierServiceBindHelper: Receive action: android.intent.action.PACKAGE_REMOVED
10-31 23:43:08.404 1566 1566 D CarrierServiceBindHelper: mHandler: 3
10-31 23:43:08.404 1138 1255 I InputReader: Reconfiguring input devices. changes=0x00000010
10-31 23:43:08.414 1925 1925 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1221 android.content.ContextWrapper.startService:581 android.content.ContextWrapper.startService:581 com.android.keychain.KeyChainBroadcastReceiver.onReceive:12 android.app.ActivityThread.handleReceiver:2725
10-31 23:43:08.418 1138 1641 I BroadcastQueue: Delay finish: com.android.keychain/.KeyChainBroadcastReceiver
10-31 23:43:08.514 1138 1255 I InputReader: Reconfiguring input devices. changes=0x00000010
10-31 23:43:08.515 1138 2212 I BroadcastQueue: Resuming delayed broadcast
10-31 23:43:08.516 1566 1566 D CarrierServiceBindHelper: Receive action: android.intent.action.PACKAGE_ADDED
10-31 23:43:08.516 1566 1566 D CarrierServiceBindHelper: mHandler: 3
10-31 23:43:08.602 1138 1255 I InputReader: Reconfiguring input devices. changes=0x00000010
10-31 23:43:08.602 1566 1566 D CarrierServiceBindHelper: Receive action: android.intent.action.PACKAGE_REPLACED
10-31 23:43:08.602 1566 1566 D CarrierServiceBindHelper: mHandler: 3
10-31 23:43:08.602 1566 1566 D CarrierConfigLoader: mHandler: 9 phoneId: 0
10-31 23:43:08.617 2390 2390 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
10-31 23:43:08.619 2390 2390 D AndroidRuntime: CheckJNI is ON
10-31 23:43:08.635 2390 2390 I art : JIT created with code_cache_capacity=2MB compile_threshold=1000
10-31 23:43:08.640 2390 2390 D ICU : No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
10-31 23:43:08.654 2390 2390 E memtrack: Couldn't load memtrack module (No such file or directory)
10-31 23:43:08.654 2390 2390 E android.os.Debug: failed to load memtrack module: -2
10-31 23:43:08.655 2390 2390 I Radio-JNI: register_android_hardware_Radio DONE
10-31 23:43:08.667 2390 2390 D AndroidRuntime: Calling main entry com.android.commands.am.Am
10-31 23:43:08.669 1138 2212 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.highway.highwaymechanic/.MainActivity} from uid 0 on display 0
10-31 23:43:08.691 2390 2390 D AndroidRuntime: Shutting down VM
10-31 23:43:08.695 2390 2395 I art : Debugger is no longer active
10-31 23:43:08.695 2390 2401 E art : Thread attaching while runtime is shutting down: Binder_2
10-31 23:43:08.695 2390 2401 I AndroidRuntime: NOTE: attach of thread 'Binder_2' failed
10-31 23:43:08.697 2402 2402 I art : Not late-enabling -Xcheck:jni (already on)
10-31 23:43:08.697 2402 2402 I art : Late-enabling JIT
10-31 23:43:08.702 2402 2402 I art : JIT created with code_cache_capacity=2MB compile_threshold=1000
10-31 23:43:08.708 1138 1712 I ActivityManager: Start proc 2402:com.highway.highwaymechanic/u0a53 for activity com.highway.highwaymechanic/.MainActivity
10-31 23:43:08.717 2402 2409 E art : Failed sending reply to debugger: Broken pipe
10-31 23:43:08.717 2402 2409 I art : Debugger is no longer active
10-31 23:43:08.728 2402 2402 W System : ClassLoader referenced unknown path: /data/app/com.highway.highwaymechanic-1/lib/x86
10-31 23:43:08.747 2402 2402 W GooglePlayServicesUtil: Google Play services is missing.
10-31 23:43:08.747 2402 2402 W GooglePlayServicesUtil: Google Play services is missing.
10-31 23:43:08.747 2402 2402 W GooglePlayServicesUtil: Google Play services is missing.
10-31 23:43:08.747 2402 2402 W GooglePlayServicesUtil: Google Play services is missing.
10-31 23:43:08.748 2402 2402 W GooglePlayServicesUtil: Google Play services is missing.
10-31 23:43:08.748 2402 2402 W GooglePlayServicesUtil: Google Play services is missing.
10-31 23:43:08.755 2402 2402 W GooglePlayServicesUtil: Google Play services is missing.
10-31 23:43:08.755 2402 2402 W GooglePlayServicesUtil: Google Play services is missing.
10-31 23:43:08.755 2402 2402 W GooglePlayServicesUtil: Google Play services is missing.
10-31 23:43:08.764 2402 2402 W GooglePlayServicesUtil: Google Play services is missing.
10-31 23:43:08.764 2402 2402 W GooglePlayServicesUtil: Google Play services is missing.
10-31 23:43:08.797 2402 2402 D gralloc_goldfish: Emulator without GPU emulation detected.
10-31 23:43:08.818 1138 1170 I ActivityManager: Displayed com.highway.highwaymechanic/.MainActivity: +129ms
10-31 23:43:10.932 1138 1429 I ActivityManager: START u0 {act=android.intent.action.VIEW dat=market://details?id=com.google.android.gms&pcampaignid=gcore_8115000--- flg=0x80000 pkg=com.android.vending} from uid 10053 on display 0
10-31 23:43:10.933 2402 2402 D AndroidRuntime: Shutting down VM
10-31 23:43:10.933 2402 2402 E AndroidRuntime: FATAL EXCEPTION: main
10-31 23:43:10.933 2402 2402 E AndroidRuntime: Process: com.highway.highwaymechanic, PID: 2402
10-31 23:43:10.933 2402 2402 E AndroidRuntime: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://details?id=com.google.android.gms&pcampaignid=gcore_8115000--- flg=0x80000 pkg=com.android.vending }
10-31 23:43:10.933 2402 2402 E AndroidRuntime: at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1798)
10-31 23:43:10.933 2402 2402 E AndroidRuntime: at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512)
10-31 23:43:10.933 2402 2402 E AndroidRuntime: at android.app.Activity.startActivityForResult(Activity.java:3917)
10-31 23:43:10.933 2402 2402 E AndroidRuntime: at android.app.Activity.startActivityForResult(Activity.java:3877)
10-31 23:43:10.933 2402 2402 E AndroidRuntime: at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:748)
10-31 23:43:10.933 2402 2402 E AndroidRuntime: at android.app.Activity.startActivity(Activity.java:4200)
10-31 23:43:10.933 2402 2402 E AndroidRuntime: at android.app.Activity.startActivity(Activity.java:4168)
10-31 23:43:10.933 2402 2402 E AndroidRuntime: at com.google.android.gms.dynamic.zza$5.onClick(Unknown Source)
10-31 23:43:10.933 2402 2402 E AndroidRuntime: at android.view.View.performClick(View.java:5198)
10-31 23:43:10.933 2402 2402 E AndroidRuntime: at android.view.View$PerformClick.run(View.java:21147)
10-31 23:43:10.933 2402 2402 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739)
10-31 23:43:10.933 2402 2402 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
10-31 23:43:10.933 2402 2402 E AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
10-31 23:43:10.933 2402 2402 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
10-31 23:43:10.933 2402 2402 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-31 23:43:10.933 2402 2402 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
10-31 23:43:10.933 2402 2402 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
10-31 23:43:10.934 1138 1712 W ActivityManager: Force finishing activity com.highway.highwaymechanic/.MainActivity
10-31 23:43:10.935 943 943 D gralloc : Registering a buffer in the process that created it. This may cause memory ordering problems.
10-31 23:43:10.935 943 943 E libEGL : called unimplemented OpenGL ES API
10-31 23:43:10.935 943 943 E SurfaceFlinger: glCheckFramebufferStatusOES error 1711643839
10-31 23:43:10.935 943 943 E SurfaceFlinger: got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot
10-31 23:43:11.448 1138 1162 W ActivityManager: Activity pause timeout for ActivityRecord{40e8f1c u0 com.highway.highwaymechanic/.MainActivity t11 f}
10-31 23:43:21.478 1138 1162 W ActivityManager: Activity destroy timeout for ActivityRecord{40e8f1c u0 com.highway.highwaymechanic/.MainActivity t11 f}
Here is my Android_manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.highway.highwaymechanic"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="23" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.highway.highwaymechanic.Map"
android:label="#string/title_activity_map" >
</activity>
</application>
</manifest>
Here is my MainActivity.java file
package com.highway.highwaymechanic;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Here is my MapsActivity.java file
package com.highway.highwaymechanic;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
#Override
public void onMapReady(GoogleMap map) {
LatLng sydney = new LatLng(-34, 151);
map.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
map.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
When run in the emulator it crashes with Unfortunately the app stopped working.
Please help me with it.
Thanks in Advance
I believe this should have been fixed with the latest release of the Google Play services client library. Note that this is a fix in the client library and so you will have to update the library to the latest revision using your SDK manager and recompile your application.
for more details you can check this link
https://code.google.com/p/gmaps-api-issues/issues/detail?id=4862
Do you have an another Activity named Map? As I see in your manifest,
<activity
android:name="com.highway.highwaymechanic.Map"
android:label="#string/title_activity_map" >
</activity>
Likewise, there should be a similar tag for the MapsActivity in your manifest. I think this is the error.
it bugs out much sooner, missing some native assembly for x86 architecture:
W System: ClassLoader referenced unknown path: /data/app/com.highway.highwaymechanic-1/lib/x86
followed by:
W GooglePlayServicesUtil: Google Play services is missing.
To add the missing Google Play (incl. Maps) Services, wrote a how-to once (it's almost the same).
While that FragmentActivity requires an IntentFilter, else it cannot be launched, for example:
<activity
android:name=".MapsActivity"
android:label="#string/title_activity_map">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
I'm building an app using the Ionic framework and AngularJS. It used to run fine, now it crashes as soon as it starts in both the emulator and an Android device. What is weird is that it runs fine in the Ionic View app (http://view.ionic.io/). The logcat says that the error is a NullPointerException.
What really worries me is that I didn't do any big changes, and another app started to fail as well. How can Ionic Cordova fail like that?
The complete logcat for the part of the crash says:
--------- beginning of crash
E/AndroidRuntime( 2227): FATAL EXCEPTION: main
E/AndroidRuntime( 2227): Process: com.ionicframework.notpush921844, PID: 2227
E/AndroidRuntime( 2227): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ionicframework.notpush921844/com.ionicframework.notpush921844.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.CordovaPlugin.privateInitialize(java.lang.String, org.apache.cordova.CordovaInterface, org.apache.cordova.CordovaWebView, org.apache.cordova.CordovaPreferences)' on a null object reference
E/AndroidRuntime( 2227): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
E/AndroidRuntime( 2227): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
E/AndroidRuntime( 2227): at android.app.ActivityThread.access$800(ActivityThread.java:144)
E/AndroidRuntime( 2227): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
E/AndroidRuntime( 2227): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 2227): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime( 2227): at android.app.ActivityThread.main(ActivityThread.java:5221)
E/AndroidRuntime( 2227): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 2227): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime( 2227): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
E/AndroidRuntime( 2227): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
E/AndroidRuntime( 2227): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.CordovaPlugin.privateInitialize(java.lang.String, org.apache.cordova.CordovaInterface, org.apache.cordova.CordovaWebView, org.apache.cordova.CordovaPreferences)' on a null object reference
E/AndroidRuntime( 2227): at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:169)
E/AndroidRuntime( 2227): at org.apache.cordova.PluginManager.startupPlugins(PluginManager.java:95)
E/AndroidRuntime( 2227): at org.apache.cordova.PluginManager.init(PluginManager.java:84)
E/AndroidRuntime( 2227): at org.apache.cordova.CordovaWebViewImpl.init(CordovaWebViewImpl.java:116)
E/AndroidRuntime( 2227): at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:138)
E/AndroidRuntime( 2227): at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:209)
E/AndroidRuntime( 2227): at com.ionicframework.notpush921844.MainActivity.onCreate(MainActivity.java:32)
E/AndroidRuntime( 2227): at android.app.Activity.performCreate(Activity.java:5937)
E/AndroidRuntime( 2227): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
E/AndroidRuntime( 2227): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
E/AndroidRuntime( 2227): ... 10 more
W/ActivityManager( 1219): Force finishing activity com.ionicframework.notpush921844/.MainActivity
I/WindowManager( 1219): Screenshot max retries 4 of Token{f511ccd ActivityRecord{230d3264 u0 com.ionicframework.notpush921844/.MainActivity t61 f}} appWin=Window{1adfb8c9 u0 Starting com.ionicframework.notpush921844} drawState=4
E/ActivityManager( 1219): Invalid thumbnail dimensions: 576x576
D/OpenGLRenderer( 1219): Render dirty regions requested: true
D/Atlas ( 1219): Validating map...
D/ ( 1219): HostConnection::get() New Host Connection established 0x9de19530, tid 2264
I/OpenGLRenderer( 1219): Initialized EGL, version 1.4
D/OpenGLRenderer( 1219): Enabling debug mode 0
W/EGL_emulation( 1219): eglSurfaceAttrib not implemented
W/OpenGLRenderer( 1219): Failed to set EGL_SWAP_BEHAVIOR on surface 0x9de3eb40, error=EGL_SUCCESS
W/ActivityManager( 1219): Activity pause timeout for ActivityRecord{230d3264 u0 com.ionicframework.notpush921844/.MainActivity t61 f}
W/EGL_emulation( 1475): eglSurfaceAttrib not implemented
W/OpenGLRenderer( 1475): Failed to set EGL_SWAP_BEHAVIOR on surface 0xb0a93b40, error=EGL_SUCCESS
W/OpenGLRenderer( 1475): Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
W/OpenGLRenderer( 1475): Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
W/OpenGLRenderer( 1475): Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
I/iu.UploadsManager( 1746): End new media; added: 0, uploading: 0, time: 28 ms
V/ConfigFetchTask( 1746): ConfigFetchTask getDeviceDataVersionInfo(): ABFEt1ViXdAKZc6rqCAOLFv7YJuwVLSY9_n4gaUyYMJPnZLeFSYFobS5FdRKHo-hnBvGnh1pycqXDTZLbzD-k5JtupkV7UW73Ugga_ju-VhYkvWRtl_Jn90jZhoDq_QYlbboOgPzzxDKH54r4FIa2bH3M1p-U8uzShc-PuRzDfha4UOokdUFujGIG2kLo5vTf6UKiU8mrJ_i-n_s1sm2CNkFb7o3Q7f_N1keqlCKSvXmpOQwTd0C7WGOOCYVnk7105hhiah5iLKl_0ZmwnXt9YnD2hVSUAQyDJPeLsFPksOqBpS6WQgtxBQ
I/GoogleURLConnFactory( 1746): Using platform SSLCertificateSocketFactory
W/ActivityThread( 1746): ClassLoader.loadClass: The class loader returned by Thread.getContextClassLoader() may fail for processes that host multiple applications. You should explicitly specify a context class loader. For example: Thread.setContextClassLoader(getClass().getClassLoader());
I/ActivityManager( 1219): Waited long enough for: ServiceRecord{39917cb u0 com.android.calendar/.alerts.InitAlarmsService}
I/ConfigFetchService( 1746): fetch service done; releasing wakelock
I/ConfigFetchService( 1746): stopping self
W/ActivityManager( 1219): Activity destroy timeout for ActivityRecord{230d3264 u0 com.ionicframework.notpush921844/.MainActivity t61 f}
I/CheckinService( 1746): Done disabling old GoogleServicesFramework version
I/ConfigService( 1598): onDestroy
D/TaskPersister( 1219): removeObsoleteFile: deleting file=61_task.xml
D/InitAlarmsService( 2008): Clearing and rescheduling alarms.
I/ActivityManager( 1219): Killing 1538:com.android.printspooler/u0a42 (adj 15): empty #17
W/libprocessgroup( 1219): failed to open /acct/uid_10042/pid_1538/cgroup.procs: No such file or directory
W/AudioTrack( 1219): AUDIO_OUTPUT_FLAG_FAST denied by client
I/Process ( 2227): Sending signal. PID: 2227 SIG: 9
I/ActivityManager( 1219): Process com.ionicframework.notpush921844 (pid 2227) has died
D/OpenGLRenderer( 1219): endAllStagingAnimators on 0xa2fe5880 (RippleDrawable) with handle 0x9deaf750
W/InputMethodManagerService( 1219): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#2a47c778 attribute=null, token = android.os.BinderProxy#344958d4
It turns out the problem was caused by adding Phonegap's PushPlugin. I just had to remove android platform with ionic platform rm android and then add it again with ionic platform add android. Works fine now in both emulator and device.