Skip to content
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

android build fails react-native < 0.65 + 2.3.0-alpha.2 + android build flavors #2245

Closed
1 of 3 tasks
mikehardy opened this issue Jul 30, 2021 · 6 comments · Fixed by #2319
Closed
1 of 3 tasks

android build fails react-native < 0.65 + 2.3.0-alpha.2 + android build flavors #2245

mikehardy opened this issue Jul 30, 2021 · 6 comments · Fixed by #2319

Comments

@mikehardy
Copy link
Contributor

Description

The < 65 version of the android build is not android build flavor aware

Expected behavior

Building with flavors should work?

Actual behavior & steps to reproduce

Building with flavors fails because the tasks depended on in the build.gradle for this module are not flavor aware, so they don't exist

Snack or minimal code example

replaceSoTaskDebug.dependsOn(
project.getTasks().getByPath("${appName}:mergeDebugNativeLibs"),
project.getTasks().getByPath("${appName}:stripDebugDebugSymbols")
)
project.getTasks().getByPath("${appName}:packageDebug").dependsOn(replaceSoTaskDebug)
replaceSoTaskRelease.dependsOn(
project.getTasks().getByPath("${appName}:mergeReleaseNativeLibs"),
project.getTasks().getByPath("${appName}:stripReleaseDebugSymbols")
)
project.getTasks().getByPath("${appName}:packageRelease").dependsOn(replaceSoTaskRelease)

An example of making them work correctly is to replace every 'Release' or 'Debug' with 'DevRelease' or 'DevDebug' in my project (I have a 'dev' flavor, and it results in tasks with 'Dev' sliced in the task names)

I think it needs some magic like an application variants loop and then set the replace task to depend on the merge/strip of each variants https://stackoverflow.com/a/63922131/9910298

Package versions

  • React Native: 0.64.2
  • React Native Reanimated: 2.3.0-alpha.2
  • NodeJS: n/a
  • Xcode: n/a
  • Java & Gradle: JDK11 + Gradle 7.1.1 + AGP7.0.0

Affected platforms

  • Android
  • iOS
  • Web
@github-actions
Copy link

Issue validator

The issue is valid!

@mikehardy
Copy link
Contributor Author

Here's an example of a repo that has a similar need, at the very top of the loop on variants they get the name, then at the bottom they do a dependsOn of a dynamic task name based on variant name. The middle will not be interesting here, but it illustrates the principle

https://github.com/oblador/react-native-vector-icons/blob/master/fonts.gradle

@mikehardy
Copy link
Contributor Author

@piaskowyk no intention to pressure (it's open source of course!) just wanted to note that 0.65 is getting very close to release, and this package is still alpha for 0.65 compatibility
I had a thought where maybe you release a major version as-is (even knowing this issue exists and is not fixed yet) with a big warning that android build variants are currently not supported in the new major version pending a fix, then when this is fixed it could land as a patch and with a changelog edit saying it's good to go now

Seems odd but even as an affected party (my app uses build variants) as long as it was semver major with a note, I think that's acceptable - it's what semver majors are for.

The warning could be "This release is intended for people upgrading to react-native 0.65. If you are using build variants in Android and are still on react-native 0.64, you should stay on reanimated 2.2.x until a fix for #2245 is contributed. Thanks")

@andresribeiro
Copy link

@mikehardy 0.65 was released today

@ghost
Copy link

ghost commented Aug 18, 2021

@piaskowyk no intention to pressure (it's open source of course!) just wanted to note that 0.65 is getting very close to release, and this package is still alpha for 0.65 compatibility
I had a thought where maybe you release a major version as-is (even knowing this issue exists and is not fixed yet) with a big warning that android build variants are currently not supported in the new major version pending a fix, then when this is fixed it could land as a patch and with a changelog edit saying it's good to go now

Seems odd but even as an affected party (my app uses build variants) as long as it was semver major with a note, I think that's acceptable - it's what semver majors are for.

The warning could be "This release is intended for people upgrading to react-native 0.65. If you are using build variants in Android and are still on react-native 0.64, you should stay on reanimated 2.2.x until a fix for #2245 is contributed. Thanks")

HI, I managed to have some problems with reanimated jus hours ago and if you don't mind me asking. You mentioned about staying on 0.64 with Reanimated 2.2.X, i wonder if my maching has something to do with it becuase Im new to RN and yarn just automatically installed 0.65 RN and 2.2.0, Now beacuse they're incompatible, I tried downgrading Rn to 0.64 or 0.63 in a guess that it might fix it. Now i managed to install 2.3.0 via the yarn install optional dialog when I touched my package the json file and reanimated was working again so 0.65 and 2.3.0 was the solution for that. I wonder if how could I safely use and run reanimated 2.2.0 and RN 0.64 for the mean time because it looks like reanimated is in alpha stage right now./ thanks. :)

@mikehardy
Copy link
Contributor Author

With apologies, I've updated the app I have with build flavors to react-native 0.65, so this issue does not affect me. I'd love to contribute a PR to fix it but I'm already maintaining a bunch of open source stuff and don't have the bandwidth to work on this since it no longer affects me and there is a fix for it that's the "happy path" anyway (upgrade to react-native 0.65...)

@piaskowyk piaskowyk linked a pull request Aug 24, 2021 that will close this issue
piaskowyk added a commit that referenced this issue Aug 24, 2021
## Description

Added support for Gradle flavor. Solution based on https://stackoverflow.com/a/34679933/7276742

Fixes
- #2245
- #2292
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants