Can't read resources when running methods from dex file

I had a jar file containing code and resources ( ResourceBundle

).
I created a simple project in android studio with this jar, compiled it, extracted .apk

and copied it classes.dex

into a second project. Also copied the resources from the extracted .apk to the second project.

From the second project, I loaded the class from the .dex file. When you run a method from this class (from a dex file) that reads a resource, it won't find it, it will throw an exception:

Caused by: java.util.MissingResourceException: Can't find resource for bundle ...

      

Invalid line:

ResourceBundle resource = ResourceBundle.getBundle("xx.yy.zz.resources.aa", Locale.getDefault());

      

If I just run:

ResourceBundle resource = ResourceBundle.getBundle("xx.yy.zz.resources.aa", Locale.getDefault());

      

from the second project (not from dex) it will work fine - get the resource.

Any ideas guys?

thank

+3


source to share


1 answer


Finally it works, wanted to share: Instead of using classes.dex, use .apk for classloader. He knows how to read functions from dex inside it and get resources from it.



0


source







All Articles