Sometimes get android.content.res.Resources$NotFoundException - android

We're debugging a crash in a Cordova app that seems to happen on launch / foregrounding, after the app was backgrounded for a moderate amount of time and has been to some extent killed by the OS.
At the time of the crash the app is attempting to show a native dialog fragment for Fingerprint Authentication. For some reason in this case the resources for this fragment cannot be found.
It's been reported for Android 6 and 7, on older and newer devices.
java.lang.RuntimeException: Unable to start activity ComponentInfo{ca.koho/ca.koho.Koho}: android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2421)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:174)
at android.app.ActivityThread.main(ActivityThread.java:5440)
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: android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:1437)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2887)
at android.content.res.Resources.getLayout(Resources.java:1251)
at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
at com.cordova.plugin.android.fingerprintauth.FingerprintAuthenticationDialogFragment.onCreateView(FingerprintAuthenticationDialogFragment.java:85)
at android.app.Fragment.performCreateView(Fragment.java:2220)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1130)
at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1953)
at android.app.FragmentController.dispatchActivityCreated(FragmentController.java:152)
at android.app.Activity.performCreateCommon(Activity.java:6279)
at android.app.Activity.performCreate(Activity.java:6287)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2374)
... 9 more
Here's the problematic bit of code, from the DialogFragment's onCreateView:
int fingerprint_dialog_container_id = getResources()
.getIdentifier("fingerprint_dialog_container", "layout",
FingerprintAuth.packageName);
View v = inflater.inflate(fingerprint_dialog_container_id, container, false);
When the crash happens, getIdentifier(...) is for some reason returning 0. Most of the time the actual identifier is returned.
I have not found a way to reproduce the crash, and advice to enable developer options like 'Don't keep activities' and 'Background process limit' had did not help.
Thanks for any help.

Related

Resources$NotFoundException for few Drawables on Vivo devices

I am getting Resources$NotFoundException mostly on Vivo devices. This is only happening for Drawable resources. I have all variant from mdpi till xxxhdpi. All these are pngs. I am unable to replicate this and only getting this on production in 4 different places. 2 of which are in splash screen and 1 is in facebook login library on this line for this drawable. Which means these users are unable to enter the app. Any idea if there some special handling that need to be done for these devices? I have never faced something like this before.
sample code
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:adjustViewBounds="true"
app:srcCompat="#drawable/splash"
app:layout_constraintWidth_max="400dp"
app:layout_constraintBottom_toTopOf="#+id/white_bg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:src="#drawable/splash"/>
here I am getting this crash due to splash Drawable.
Stack Trace
Caused by android.content.res.Resources$NotFoundException Unable to
find resource ID #0x7f08013d
com.myapp.ui.splashScreen.SplashScreenActivity.onCreate
Caused by android.content.res.Resources$NotFoundException: Unable to
find resource ID #0x7f08013d
at android.content.res.ResourcesImpl.getResourceName(ResourcesImpl.java:292)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:879)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:749)
at android.content.res.Resources.loadDrawable(Resources.java:922)
at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:953)
at android.content.res.TypedArray.getDrawable(TypedArray.java:928)
at android.widget.ImageView.(ImageView.java:188)
at android.widget.ImageView.(ImageView.java:171)
at androidx.appcompat.widget.AppCompatImageView.(AppCompatImageView.java:72)
at androidx.appcompat.widget.AppCompatImageView.(AppCompatImageView.java:68)
at androidx.appcompat.app.AppCompatViewInflater.createImageView(AppCompatViewInflater.java:187)
at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:107)
at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1266)
at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1316)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:817)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:775)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:908)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:869)
at android.view.LayoutInflater.inflate(LayoutInflater.java:521)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:141)
at com.myapp.ui.splashScreen.SplashScreenActivity.onCreate(SplashScreenActivity.java:81)
at android.app.Activity.performCreate(Activity.java:7129)
at android.app.Activity.performCreate(Activity.java:7120)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2906)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3031)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1732)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:192)
at android.app.ActivityThread.main(ActivityThread.java:6792)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:826)
I had the same issue for Vivo phones almost exclusively, I then added the image to a noDpi and that resolved it.

Android : Window couldn't find content container view after adding file in raw folder

Am getting an Window couldn't find content container view. This error asking when the app is going to checking the permission
I noticed that for the wear app , am copying the wear apk into the raw folder.
Its having around 2.5 Mb. After adding this am getting this crash
java.lang.RuntimeException: Window couldn't find content container view
at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:4614)
at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:4683)
at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:2263)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4276)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3361)
at android.app.ActivityThread.access$1100(ActivityThread.java:222)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Comscore library was causing this issue in my case. Try removing it.

Android strange ClassCastException

A few days ago we started to receive some crash reports from users using our app, but the stracktrace is really strange. It happens only on Samsung G900f (S5) and I can't reproduce it and decide to post a question here.
The stacktrace shows this:
Caused by java.lang.ClassCastException: android.support.design.widget.CollapsingToolbarLayout cannot be cast to android.support.design.widget.CollapsingToolbarLayout
at com.packageName.profile.ProfileFragment.onViewCreated(SourceFile:423)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1086)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1248)
at android.support.v4.app.BackStackRecord.run(SourceFile:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(SourceFile:1613)
at android.support.v4.app.FragmentController.execPendingActions(SourceFile:330)
at android.support.v4.app.FragmentActivity.onStart(SourceFile:547)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1234)
at android.app.Activity.performStart(Activity.java:6258)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2621)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2725)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5834)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
It is a Fragment which contains CollapsingToolbarLayout with initialization and use all correct, but not sure why this happens.
We got some other ClassCastExceptions with different classes from the same device. For example:
Caused by java.lang.ClassCastException:
com.packageName.model.VideoMeta cannot be cast to
com.packageName.model.VideoMeta
where VideoMeta is a class which implements Parcelable and this exception occurs in class Video which implements Parcelable too:
private Video(Parcel in) {
id = in.readLong();
postId = in.readString();
url = in.readString();
thumb = in.readString();
meta = (VideoMeta) in.readValue(VideoMeta.class.getClassLoader());
}
But that's not the end...
Caused by java.lang.ClassCastException:
android.support.design.widget.AppBarLayout$LayoutParams cannot be cast to
android.support.design.widget.AppBarLayout$LayoutParams
I have no idea what can cause this exception and why it's happening, that's why posting it here.
Thanks in advance for any kind of help or suggestions!

How to debug internal crash of GLSurfaceView?

I'm developing a VR video viewer using Android Cardboard SDK and RajawaliVR (https://github.com/Rajawali/RajawaliVR)
On some devices I have this crash when returning from sleep (others just show black screen):
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.opengl.GLSurfaceView$GLThread.surfaceCreated()' on a null object reference
at android.opengl.GLSurfaceView.surfaceCreated(GLSurfaceView.java:523)
at android.view.SurfaceView.updateWindow(SurfaceView.java:580)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:176)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1970)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5891)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:550)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
As you can see the crash is in the android code, how do I start debugging it?
You have access to the source code, so start with that.
Assuming you're using Lollipop, it's failing on this line:
mGLThread.surfaceCreated();
The error message indicates that mGLThread is null. Doing a simple search for the assignment ("mGLThread =") with the web browser reveals two instances, the most interesting of which is this one:
public void setRenderer(Renderer renderer) {
...
mGLThread = new GLThread(mThisWeakRef);
Setting some of the complexities aside, mGLThread should be non-null so long as setRenderer() is called. So the first thing to do is check to see if your application is calling setRenderer() (typically in onCreate()).
If you're following along the Android Developer OpenGL tutorial, it's possible that Android Studio corrected this definition in your Activity class constructor:
mGLView = new MyGLSurfaceView(this);
and changed it to
mGLView = new GLSurfaceView(this);
because the class MyGLSurfaceView had not been coded yet...skipping the MyGLSurfaveView constructor which is where setRenderer(...) is called. Mr. fadden's answer above is excellent, explains how to diagnose the problem.

Android app crash after open other apps

I have a problem with my app. The app works perfectly. If I press the back button the app obviously closes without any problems. If I press the home button the app is in the background. If I open the app immediately this works, but if I open other apps and then I open my app often crashes.
How can I fix? I have to implement the method onPause? But how?
26 21:46:27.341 29621-29621/parlamento_italiano.android E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: parlamento_italiano.android, PID: 29621
java.lang.RuntimeException: Unable to start activity ComponentInfo{parlamento_italiano.android/com.prova.prova3.Quarta}: java.lang.NumberFormatException: Invalid int: ""
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3119)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3218)
at android.app.ActivityThread.access$1000(ActivityThread.java:198)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1676)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6837)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.NumberFormatException: Invalid int: ""
at java.lang.Integer.invalidInt(Integer.java:138)
at java.lang.Integer.parseInt(Integer.java:358)
at java.lang.Integer.parseInt(Integer.java:334)
at com.prova.prova3.R2.onCreateView(R2.java:77)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1026)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1207)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1189)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2001)
at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:165)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:507)
at com.prova.prova3.Quarta.onStart(Quarta.java:291)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1250)
at android.app.Activity.performStart(Activity.java:6538)
This cause the crash
int x = Integer.parseInt(numVoti.replaceAll("[\\D]", ""));
Firstly, your app does not go in the background, when you press the Home button. It just gets added in the Back Stack. Second, try to explain to us the resources your app uses, how they interact with other apps, possibly.

Categories

Resources