I am getting a crash on Android Lolipop.
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.content.res.StringBlock.get(int)' on a null object reference
at android.content.res.AssetManager.getResourceValue(AssetManager.java:213)
at android.content.res.Resources.getValue(Resources.java:1334)
at android.content.res.Resources.getValue(Resources.java:1323)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2796)
at android.content.res.Resources.getLayout(Resources.java:1143)
at android.view.LayoutInflater.inflate(LayoutInflater.java:412)
Generally happens while inflating a view.
Any suggestions why it happens on Lollipop only ?
It is may be because of an attribute is null.
For example android:foreground="?android:attr/selectableItemBackground" may be null, try to use android:foreground="?attr/selectableItemBackground".
In my case it occurred when I was setting a image to notification from service . I remove the relevant code and it started working fine
Related
I'm facing a very annoying android crash that happens in around 1% of PRODUCTION the sessions with the app ALWAYS in the background.
Fatal Exception: android.app.RemoteServiceException: Attempt to invoke virtual method 'int com.android.server.wm.TaskDisplayArea.getDisplayId()' on a null object reference
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2054)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:250)
at android.app.ActivityThread.main(ActivityThread.java:7755)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
From this stack is clear that it comes from an internal android MainLooper operation... but the lack of extra information difficult for me to discover WHAT exactly
does anyone know what is this problem and how to solve it?
There's not a whole lot we can do with this level of information. The only thing I can see is this:
android.app.RemoteServiceException: Attempt to invoke virtual method 'int com.android.server.wm.TaskDisplayArea.getDisplayId()' on a null object reference
At some stage, your code is calling (or using a library which calls) getTaskDisplayArea() in com.android.server.wm. This returns null. It then tries to use this to getDisplayId().
(The rest of the error lines there just indicate it's not in the main thread)
It's likely that wherever you're using the TaskDisplayArea (or the library that calls it) is being called when the UI has been destroyed or has yet to be created.
The rarity indicates it probably is a total background restart of your UI/display elements... if I had to guess maybe caused by Android OS memory cleanup triggers while multitasking, or the user changing orientation repeatedly, etc etc.
If you give more details about where you've used the com.android.server.wm code or layouts you can probably get more help for how to make this background-thread-proof. Depending on what you're actually doing you might end up just catching the exception & retrying later, but some views will allow you to post info to the main thread and I don't know if TaskDisplayArea does.
In my case, I found that the project had a notification icon file in res/drawable-v24/ic_launcher_foreground.xml. The crashing stopped when I moved the .xml associated with v24 in the drawable res folder.
I am making my edittext to material design (using TextInputLayout).It is working fine .But when I click on my DatePicker the app is crashing saying:
Attempt to invoke virtual method 'int android.widget.NumberPicker.getChildCount()' on a null object reference
My gradle file as below
apply plugin: 'com.android.application'
I don't understand, removing the TextInputLayout fixes the problem...
NOTE: I have defined Theme.AppCompat.Light in manifest
Your NumberPicker is null, It is either not initialized or If you have used findViewById, It has not been found, therefore, calling getChildCount on a null object will throw NullPointerException.
Try to resolve the NumberPicker reference and make sure that it is not null and found in your View/Activity/Fragment.
Attempt to invoke virtual method 'int
android.widget.NumberPicker.getChildCount()' on a null object
reference
From this, you can see that the exception is a NullPointerException. and it says that, getChildCount() method was called on a null point. Which means that, the object of type NumberPicker is null.
So, if you've initialized the object, please check the initialization part of your code. And your findViewById might be also not working as well if the ID wasn't found in the XML file.
So I just released a new beta today with no changes to this piece of code. Strangely enough I got a new crash I've never seen before reported on Crashlytics. It has only happened to 2 users from two different manufacturers on Android 6 and 7. So it isn't a huge deal yet but I would still like to get it fixed.
Anyone have any idea what might be the issue here?
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.content.res.StringBlock.get(int)' on a null object reference
at android.content.res.AssetManager.getResourceValue(AssetManager.java:206)
at android.content.res.Resources.getValue(Resources.java:1540)
at android.content.res.Resources.getDrawable(Resources.java:918)
at android.content.Context.getDrawable(Context.java:463)
at android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.java:30)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:372)
Thanks.
Here is the code that causes the issue:
#Override
public Drawable getDefaultPlaceholderImage() {
return ContextCompat.getDrawable(this, R.drawable.default_placeholder);
}
I have the similar crashes at some devices (Samsung GT-I9505, Android 5). The error happens while parsing xml of the image. The cause of the error is the number with two points in the xml (it was "1.84.63" in my xml). Try to create all xml of images by another converter (for example, Vector Asset Studio).
I have and existing android app developed with Xamarin.
It works perfect.
I decided to create a widget for my app, and I followed
Xamarin Widget Sample, http://forums.xamarin.com/discussion/22941... and Vogela Widget tutorial guidelines to add what it's needed.
Unfortunately since them the app crashes on start with this exception
Java.Lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.ContentFrameLayout.setId(int)' on a null object reference
The problem comes because when loading the first activity and doing base.OnCreate (savedInstanceState); Bundle savedInstanceState is null.
I finally found the error by myself.
It seems the xml folder gives some errors on xamarin android.
I just moved the contento to layout and reference it as layout/ instead of /xml
Another solution as mentioned here
delete bin and obj folders on Android project and rebuild it
I've been seeing this crash for a very small percent of users.
Fatal Exception: java.lang.NullPointerException
Attempt to invoke interface method 'boolean android.view.inputmethod.InputConnection.finishComposingText()' on a null object reference
called from android.view.inputmethod.InputConnectionWrapper.finishComposingText (InputConnectionWrapper.java:78)
The stack trace is all from Android system code, so I'm not sure how I'm triggering the crash. I think it has to do with how I've overridden the InputConnection on a WebView, but I'm not sure how exactly it's caused. Has anyone else seen this error or know how to fix it?
This was caused by Google employees dog fooding a new version of the webview. onCreateInputConnection in InputConnectionWrapper sometimes returns null now and you need to check that before using it to instantiate RichTextInputConnection.