In My app When I go to the settings activity then back, my app force to stop the activity, I don't know which mistake is there.Please help me to solve that. Thanks for your help in advance!
08-13 11:36:36.355 21968-21968/com.example.user.dictationapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.user.dictationapp, PID: 21968
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.user.dictationapp/com.example.user.dictationapp.DictationVocab}: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.CompoundButton$SavedState
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2202)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2252)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.CompoundButton$SavedState
at android.widget.CompoundButton.onRestoreInstanceState(CompoundButton.java:378)
at android.view.View.dispatchRestoreInstanceState(View.java:12842)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2658)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2658)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2658)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2658)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2658)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2658)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2658)
at android.view.View.restoreHierarchyState(View.java:12820)
at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1874)
at android.app.Activity.onRestoreInstanceState(Activity.java:949)
at android.app.Activity.performRestoreInstanceState(Activity.java:921)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1138)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2252)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
at dalvik.system.NativeStart.main(Native Method)
android.view.AbsSavedState$1 cannot be cast to android.widget.CompoundButton$SavedState
Having experienced these ClassCastExceptions before, I'd suggest that you check that you do not have a same id being shared by different widgets. Also, check with layouts in different layout-qualifiers folders for the same condition.
Related
I have a class ABCReceiver which extends WakefulBroadcastReceiver.
Intent serviceIntent = new Intent(context, DEFService.class);
serviceIntent.putExtras(intent);
startWakefulService(context, serviceIntent);
On GalaxyS4 device with OS 4.4.2, I get following exception:
`Non-fatal Exception: java.lang.RuntimeException: Unable to start receiver com.application.ABCReceiver: java.lang.RuntimeException: Parcel android.os.Parcel#2e8c37a4: Unmarshalling unknown type code 7274595 at offset 248
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2426)
at android.app.ActivityThread.access$1700(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5021)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.RuntimeException: Parcel android.os.Parcel#2e8c37a4: Unmarshalling unknown type code 7274595 at offset 248
at android.os.Parcel.readValue(Parcel.java:2080)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2314)
at android.os.Bundle.unparcel(Bundle.java:249)
at android.os.Bundle.putInt(Bundle.java:470)
at android.content.Intent.putExtra(Intent.java:5553)
at android.support.v4.content.WakefulBroadcastReceiver.startWakefulService(WakefulBroadcastReceiver.java:88)
at com.application.ABCReceiver.onReceive(LocationReceiver.java:17)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2419)
at android.app.ActivityThread.access$1700(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5021)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643)
at dalvik.system.NativeStart.main(NativeStart.java`
I am unable to reproduce this error. Kindly, help me in understanding what exactly is happening here and how can fix this error.
Thanks in advance.
If application stay in background mode more then 5 min. after that i try to open Application at that time got crash issue my Error log is here help me thanks in Advance....
java.lang.RuntimeException: Unable to start activity` ComponentInfo{com.gamestruct.TweetBoostAndroid/com.gamestruct.TweetBoostAndroid.TabbedActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gamestruct.TweetBoostAndroid/com.gamestruct.TweetBoostAndroid.EarnCoinActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2205)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2255)
at android.app.ActivityThread.access$800(ActivityThread.java:142)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5118)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gamestruct.TweetBoostAndroid/com.gamestruct.TweetBoostAndroid.EarnCoinActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2205)
at android.app.ActivityThread.startActivityNow(ActivityThread.java:2043)
at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:749)
at android.widget.TabHost.setCurrentTab(TabHost.java:413)
at android.widget.TabHost.addTab(TabHost.java:240)
at com.gamestruct.TweetBoostAndroid.TabbedActivity.addTab(TabbedActivity.java:199)
at com.gamestruct.TweetBoostAndroid.TabbedActivity.setTabs(TabbedActivity.java:180)
at com.gamestruct.TweetBoostAndroid.TabbedActivity.onCreate(TabbedActivity.java:140)
at android.app.Activity.performCreate(Activity.java:5275)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169)
... 11 more
Caused by: java.lang.NullPointerException
at com.gamestruct.TweetBoostAndroid.EarnCoinActivity.onCreate(EarnCoinActivity.java:110)
at android.app.Activity.performCreate(Activity.java:5275)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169)
... 23 more
While your application stayed in the background it got killed by the system. Somewhere in com.gamestruct.TweetBoostAndroid.EarnCoinActivity.onCreate (presumably on line 110) you are using something that became null as your app was killed.
I am Building an Npuzzle App.
The current issue I face is bringing a drawable object into my Activity so that I can convert it to a bitmap for splitting. I have found and attempted to use this Approach:
Drawable hold = Puzzle.this.getResources().getDrawable(R.drawable.img1);
BitmapDrawable hold2 = (BitmapDrawable) hold;
Bitmap bitPhoto = hold2.getBitmap();
When I run my app I get a null pointer exception in the first line of code. Any suggestions on how to fix this problem? this is the logcat when i run the program:
11-25 12:07:46.441 5388-5388/com.example.anthony.puzzler E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.anthony.puzzler/com.example.anthony.puzzler.Puzzle}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2034)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
at android.app.ActivityThread.access$700(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4950)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.content.ContextWrapper.getResources(ContextWrapper.java:81)
at com.example.anthony.puzzler.Puzzle.<init>(Puzzle.java:28)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2025)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
at android.app.ActivityThread.access$700(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4950)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
at dalvik.system.NativeStart.main(Native Method)
Clean up your project and rebuild it to make sure the id of the drawable is the correct one.
Check if getResources() is actually returning something.
Edit: calling getResources() before super.onCreate() method returns, it causes NPE.
Why don't you just directly get the media as a bitmap?
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.img1);
Should be simpler than getting a drawable and casting it.
I am trying my hand at developing simple apps with the Android Studio and I cannot seem to run even the default app with a blank activity containing the string "Hello World". When I try and run a device on a running Emulator, it gives me an error message and says it the app is not compatible on a watch. I don't know why it would think the emulator is a watch, but I don't know why I cannot emulate an app without changing anything manifest on the simplest AVD provided. Here is an image of the compatibility http://imgur.com/DEWoaON
08-26 16:09:16.500 733-733/com.example.mac.trial3 E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.mac.trial3, PID: 733
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mac.trial3/com.example.mac.trial3.MyActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
at android.app.ActivityThread.access$800(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5026)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
at android.app.Activity.setContentView(Activity.java:1930)
at com.example.mac.trial3.MyActivity.onCreate(MyActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5242)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
at android.app.ActivityThread.access$800(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5026)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
I really don't know what's going on with the Android app I'm building. At some point on its development, I started getting it breaking as soon as it starts in the emulator, with the message "Foo stopped". Here is the error log, if anyone could help me:
07-05 21:13:30.063 7647-7647/root.fazerumsom E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: root.fazerumsom, PID: 7647
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{root.fazerumsom/root.fazerumsom.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.content.ContextWrapper.getResources(ContextWrapper.java:89)
at android.view.ContextThemeWrapper.getResources(ContextThemeWrapper.java:78)
at root.fazerumsom.MainActivity.<init>(MainActivity.java:31)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2101)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
You're calling getResources() from a field initializer. Something like
private String mStr = getResources().getString(...);
(or with drawables or other kind of resources).
This is not valid, since the Context isn't set up yet. Move this assignment inside the onCreate() method.
The checked exception java.lang.NullPointerException is thrown when you're trying to use an object without reference,in simple words that means: you're trying to use a object variable without value.
Remember that a variable hold bits, primitive and non-primitive variable do, but the difference is that primitive variable hold the value in bits, but non-primitive variable hold the bits (like a direction) to access the object in memory, and when it's not being used anymore GGC (Garbage Colector) kills it.