Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't find layout ID for < 1% of users?

Tags:

android

I have an app which gets several thousand users a day. I'm getting a handful of reports through marketplace that my entry activity can't load its layout xml resource. I don't see how this could be possible?:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.me.app/com.me.app.MyActivity}: **android.content.res.Resources$NotFoundException: Resource ID #0x7f030065**
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
at android.app.ActivityThread.access$1500(ActivityThread.java:121)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3701)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030065
at android.content.res.Resources.getValue(Resources.java:896)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:1873)
at android.content.res.Resources.getLayout(Resources.java:735)
at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
at android.app.Activity.setContentView(Activity.java:1657)
at com.me.app.MyBaseActivity.setContentView(MyBaseActivity.java:50)
at com.me.app.MyActivity.onCreate(MyActivity.java:116)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
... 11 more

The exception points to this line:

setContentView(R.layout.my_layout);

Any ideas what I could be doing wrong here? Again, for 99% of users, no problem.

Thank you

like image 799
user291701 Avatar asked Sep 30 '11 11:09

user291701


2 Answers

I agree with the comments on the question that troubleshooting resource ID 0x7f030065 is the key to understanding these error reports.

I'm assuming that resource is NOT the my_layout file. Despite my_layout being pointed to as the line of the problem, it most likely is not the root issue. Something inside the my_layout file is referring to resource 0x7f030065. The layout inflater often does not report these errors very clearly.

If there isn't a version of 0x7f030065 in a default folder (ex: drawable instead of drawable-landscape), then perhaps the 1% is running in a configuration that can't find it is falling back to the non-existent default. This could be possible even if your app is locked in landscape orientation for instance - occasionally a portrait draw could still happen - even if it's not visible to the end user.

Is it always the same resource id? That's a good thing to pay attention to.

In my experience, other issues like running out of memory can cause these sorts of inflate time exceptions. If resource 0x7f030065 refers to a custom layout class, then anything that happens in the constructor of that class could possibly result in a Resources$NotFoundException

like image 153
Stan Kurdziel Avatar answered Nov 14 '22 01:11

Stan Kurdziel


I have experienced something similar. I was having an activity that I wanted to show only in landscape - so in AndroidManifest.xml I had android:screenOrientation="landscape". Than a folder layout-land and there my layout file.

From time to time, randomly, I was getting a Resources$NotFoundException when the activity was trying to load the main layout.

I solved it by renaming folder layout-land to layout.

But I think we hit some kind of bug in android.

like image 1
danidacila Avatar answered Nov 14 '22 02:11

danidacila