I am in the process of developing an application (i.e.: base apk) which is capable downloading, when the need raises, third party apks(i.e.: external apks) from a dedicated server. When that happens the base application (base apk) begins to instantiate each previously downloaded apk (i.e.: external apks) in a way similar to that elaborated here. The whole process flows smoothly except in cases where those third party apks are designed so as to take advantage of local to themselves resources (i.e.: res/layout/Layout files). In such cases 3rd party apk’s code used to access those local resources (e.g.: by trying to inflate a layout as shown below) fails throwing a NULLPointerException(being unable to locate each of them).
I wonder whether or not this is a feasible scenario. If yes (most probably I guess) is there any straight forward solution/work-around that currently I dismiss..?
LayoutInflater.from(this.getContext()).inflate(mypackage.external.apk.R.layout_to_be_loaded, this);
Thank you!
Which is insecure, offering the possibility of a code-injection attack. I would not touch that technique with a ten-foot pole.
Not really. You are ripping the bytecode out of a foreign non-installed APK and executing it in your process. You have no way to somehow rip out the resources as well and get them blended in with yours.