-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannont load classes which come from different package names which have a common relevant prefix #3
Comments
Hello. Given the structure of your APK, and the code that you provided, it also seems to me that you should be able to load both classes as long as the APK is properly signed using the private key associated to the certificate linked to the "com.impecabel.playerwrapper" package name prefix. So this could be indeed a bug in the code. I've just released a new version of Grab'n Run (1.0.3), where I have fixed several bugs and written a proper test suite for all the classes of the library. Please update your build.gradle file in the app module to use version 1.0.3, run again your code, and let me know whether the problem is solved or not. Hope this helps :) |
Hi, Ok, tomorrow i'll try with 1.0.3 and let you know how it goes. Thanks for the quick reply. |
Hi, I've just tried with version 1.0.3 and the result is the same :( Thanks in advance |
Hi, I've changed the extension of my library from apk to jar and i was able to load all the classes in all sublevels. |
Now I see the problem, and I can also state that this is not a bug in Grab'n Run, but indeed the correct behavior. APK by definition should only have one unique package name, which is defined when you create your application in an IDE, it is stored in the manifest, and it is used to identify your app on Google Play store. The easiest fix is, as you said, to simply move all the classes that you want to dynamically load into a jar archive (there you will be able to maintain your current hierarchy) and you can have more than one package name. Does it make sense to you? :) |
I understand what you've said, and so far i see no problem with the extension change (apk -> jar) workaround. Thanks in advance |
After a quick search I have not found any resource stating directly whether an apk with multiple hierarchy levels for its java classes should be considered as a good, or bad practice. Anyway, I still tend to think that using different package names for the java classes into the same APK could be confusing or misleading (especially now that Gradle allows you to add flavors with different suffix to the application id), so I would rather prefer not doing it. However, since I'm missing data points, I can't really state that the other approach is wrong. |
Anyway, if you are able to provide me with some references making your point on having multiple package names in the same apk, I'll be more than happy to change the implementation to support this case. This would actually simplify the code (in the SecureDexClassLoader.getPackageNamesFromContainerPath method, I would have just to remove the distinction between apk and jar, and consider everything as a jar archive). Otherwise, let me know and I will close this issue since it should have been solved. |
Hi, |
Jose, we internally discussed this, and we agree with you! @lukeFalsina will take care of this ASAP and will let you know! |
Ok, thanks. :) |
Hi again Jose, I've released a new version (1.0.4) that should solve your issue. Let me know whether everything works now :) |
Jose, |
Hi, Thanks for the help. |
Hi,
First of all, thanks for you excellent work on this library. this is really usefull. :)
I'm trying to use Grab-n-Run to dynamically different classes on one apk.
In my apk i have a structure like this:
Based on the sample app provided i made the following code:
When i try to load com.impecabel.playerwrapper.Player everything works fine and the class is loaded, but when i try to load the com.impecabel.playerwrapper.utils.CustomSettings it doesn't work and i get "This time the chosen class should pass the security checks!" on the logs.
Lookint at the documentation i think this should work. I'm i missing something?
If i put all the classes under com.impecabel.playerwrapper the both load.
Can you help? Do you need any logs?
Tanks in advance.
The text was updated successfully, but these errors were encountered: