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


source to share





All Articles