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
x/mobile/bind: Reflection to get ApplicationContext is disallowed on Android P (API Level 28) and causes a crash on Android Q #31364
Comments
I introduced a fix: golang/mobile#31 |
With the Play Store now giving warnings, can we look at this or another solution getting merged? |
It looks like the fix makes |
|
I think you meant BTW, (this is an off topic but,) I started to wonder if reverse binding would be better than EDIT: nvm, the reverse binding is available only at the package specified by gomobile command, then this cannot be a substitute for RunOnVM. |
Yes, sorry quick reply from my phone. I edited my original post. |
Problem
For loading gobind-libraries on Android, currently the non-SDK method
android.app.AppGlobals.getInitialApplication
is used via reflection in LoadJNI.java to provide theApplicationContext
to the native-library.Usage of non-SDK methods is not allowed in Android P and up (API level 28 and higher), for more information see: developer.android.com: Restrictions on non-SDK interfaces
From Android Q on this prevents an gobind-library from loading and causes an exception:
Solution
I think we should consider asking the
ApplicationContext
to be provided by the application when loading the gobind-library instead of acquiring it via reflection.An proposal to defer context-binding was discussed in #12725. Another option would be to defer loading of the library itself.
The text was updated successfully, but these errors were encountered: