-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
fix(android): make template / rn-tester Android 12 compatible #32540
Conversation
- bump targetSdkVersion / compileSdkVersion to 31 - add required `android:exported` notations for activities in AndroidManifest / docs
hey, that's for contributing this! |
hey @ShikaSD yeah - the changes are tiny and pretty important so I am not surprised if it is duplicate. I was building with JDK11 during my initial round of testing, but just to make sure I just did this:
and received: openjdk full version "1.8.0_302-8u302-b08-0ubuntu2-b08" Then this works as well:
Then in my Android12Test init app I did this in the android directory:
It all works. This should not be blocked on any JDK11 issues I think. |
CI failure analyze_code is eslint issues, not touched in this PR, not related |
Base commit: e918362 |
Base commit: e918362 |
Okay @ShikaSD this appears to be proof there are no JDK dependencies for this to work: https://app.circleci.com/pipelines/github/facebook/react-native/10992/workflows/be8368b7-8ef7-4671-b057-6ebc3a3e232f/jobs/224244 Only CI failures are unrelated, and it works for android in CI and local testing with JDK11 or JDK8 Hopefully this may be considered for merge |
In conversation on Discord, it was requested that an attempt be made to move
But this PR, just moving the rn-tester app and template seem fine. |
Thanks, @mikehardy. I'm going to import this and ask @ShikaSD to take a closer look using internal tools. |
@yungsters has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Sounds good - I think the general sentiment was that unblocking JDK11 and moving ReactAndroid to api 31 at the same time was ideal, at which point this is abandoned, but if this works now and JDK11 doesn't look like it'll happen, it'll at least get new users' apps on 31 from template init :-). Cheers |
Quick update here… @ShikaSD and @cortinico are investigating the best path forward. |
Fixed by #32606 |
Beautiful! I know that was one of those seemingly small changes that actually rippled out everywhere and only looked small. I appreciate it. Cheers! |
Summary
The stock new app template is not Android-12 compatible, and I did not notice any issues or PRs opened for it when I searched, though I may have missed it? So I'm proposing what I think are the necessary changes so new apps work on Android 12 out of the box
Changelog
[Android] [Fixed] - updated new app template and rn-tester for Android 12 support
Test Plan
template/package.json
to replace react-native version1000.0.0
with0.67.0-rc.2
template/android/app/src/debug/.../ReactNativeFlipper.java
to revert this change which makes ReactNativeFlipper incompatible with the react-native 0.67-0-rc.2 release (ce74aa4#diff-1e429281c560d83c035cbe6f50683ada72292f7860de108d420fb55185ababad)npx react-native init Android12Test --template git@github.com:mikehardy/react-native.git#android12
cd Android12Test && npx react-native run-android
Those test steps worked for me
I assume rn-tester is tested in CI? If not it will clearly work or clearly blow up when run, but I did check locally:
yarn install
./gradlew :packages:rn-tester:android:app:installJscDebug
(this is where it would fail if there was a problem)./scripts/packager.sh
Note that I am able to pop up the android debug settings (the DevSupportActivity) with
ctrl-M
on linux but I am simply not able to get the emulator shake to bring it up with exported:true or exported:false. Just in case, and since it is debug only I labeled that activity exported:true to make sure it could be called if needed.If someone with more knowledge of how and when DevSupportActivity is used in the ecosystem it may be possible to have this as exported:false safely.