-
Notifications
You must be signed in to change notification settings - Fork 54
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
JNI_OnLoad
-like callback to load APK classes with env.FindClass()
?
#169
Comments
I've answered the same question on your repository a while ago: astonbitecode/j4rs#102 (comment) Does that help? |
In fact it looks like your example/reproduction repository was a fork from my |
As far as I understand, this answer implies implementing the Activity and using |
@astonbitecode I don't understand what "this answer implies implementing the Activity" is supposed to mean. You asked this question in the While Separate from this, since you mentioned threading, I do wonder if android-activity/android-activity/src/native_activity/glue.rs Lines 827 to 853 in 0d29930
|
Ok apparently I did not express myself correctly. I wanted to stress that my question is whether I can achieve classloading as described, without writing any java code myself. I was thinking that using the Maybe I am wrong, but I believe this would be possible if the If this cannot be done, then I would propose to have a function similar to
|
Excuse me, I'd like to provide a few clues here (maybe off-topic):
|
@astonbitecode you can, via JNI, without writing any Java code: this is demonstrated by the example I already linked. The Java code in that repository is the class that we are loading from the APK in the first place.
That would not be possible since this function has to return: a thread needs to be spawned at some point if the user wishes to attach a looper and use it as a regular There are however a lot of refactors ongoing to detach this such that multi-activity support finally becomes possible. At this point we might consider an interim "must-return-from" |
Thanks. I opened this issue with the hope that I hope this week I will find some time to implement support of using the Classloader of the |
Ok so, I was able to use Thanks for the help. @MarijnS95, from my side, the issue can be closed. However I leave it up to you to close it, in case you want to use it to implement something similar to |
I think this is exactly what was already discussed and provided in a comment on your repo, but sounds like you resolved this in the end 👍 I think we could leave this issue open to track the potential of having a " |
JNI_OnLoad
-like callback to load APK classes with env.FindClass()
?
Hi,
I am having classloading issues when using
android-activity
and try to load classes of code that is being shipped within the same apk.The system classes that are available by default (eg.
java.lang.String
) can be found and loaded with no issues. However, the custom classes cannot be found...I wonder if the reason is what is described here:
I see in
android-activity
README that indeed the rust applications do not run on application's main thread:Can it be the reason?
I also tried to use the
JNI_OnLoad
in order to cache theJavaVM
and use it later, as it is proposed, but it does not gets called either.So, my question is, does
android-activity
support using jni to call classes shipped within the same apk? Do you have any pointers on how to achieve that?I have this gitjub repo, where you can find my scenario if this can help.
Thanks!
The text was updated successfully, but these errors were encountered: