NPE on inflating layout from different packages

I inflate the layout from a different apk (plugin) than mine (same signature) and inject it into my Activity (core) class.

XmlResourceParser freeLayoutRes = getLayoutResourceByResourceId(R.layout.freelayout);
View freeLayoutView = LayoutInflater.from(freeLayout.getContext()).inflate(freeLayoutRes, freeLayout);

      

FreeLayout is the parent for embeddable freelayoutres. The getLayoutResourceByResourceId method is a call to the main package that gets a resource from packagemanager, for example:

getPackageManager().getResourcesForApplication(pluginapp).getLayout(layoutId))

This works well, but some users reported NullPointerException to me:

java.lang.NullPointerException
        at android.view.LayoutInflater.inflate(LayoutInflater.java:435)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:372)
        at ....

      

I cannot explain and reproduce why (and when) the error occurs. On my test devices and on different emulators, the problem has not appeared yet. Also there is no hint in users stacktraces to solve this problem (different devices, different Android versions, when starting the application, after returning to Activity).

EDIT: This seems to be happening mostly on Amazon Kindle Fire devices (Android 2.3.4 and 4.0.4)

Does anyone see the problem? If you need more information, please ask.

Any help and hints would be great Danny

+3
android nullpointerexception layout-inflater


source to share


No one has answered this question yet

Check out similar questions:

5641
What is the difference between "px", "dip", "dp" and "sp"?
2735
Stop EditText from getting focus when Activity starts
1177
What is the difference between match_parent and fill_parent?
1152
Difference between gravity and layout_gravity on Android
1002
Grid motion detection
862
What are the "tools: context" in android layout files?
205
Avoid passing null as the root of the view (need to allow layout options on the root element of the inflated layout)
177
How to inflate one view with a layout
1
The app works on all tablets, but does not work on phone devices
-3
Failed to start Activity ComponentInfo android.view.InflateException: XML binary string # 63: class inflate error <unknown>



All Articles
Loading...
X
Show
Funny
Dev
Pics