-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 build.gradle doesn't work with flavors #2564
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for PR and good explanation! Of course, your idea is reasonable, but with the current form of regex, it doesn't work properly because you return NOT-FOUND
also if someone doesn't have any flavor name. It is no difference between ranromTaskName
and assembleDebug
, in both ways it will be returned NOT-FOUND
. You need to change the regex
(assemble|bundle|install|generate)(\w+)(Release|Debug)
to
(assemble|bundle|install|generate)(\w*)(Release|Debug)
If you don't mind, I will correct this regex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the help! 🚀
Has this been released already? edit: it hasn't yet ;) |
I still have this issue on 2.2.4 :( |
Yes it is related. Had this too. |
Fixed on 2.2.4 |
Hi! It seems like I'm experiencing an error that might be related to these changes. The error appeared recently and the same command was working before and it seems that
The error can be circumvented by explicitly using the flavor name in the bundle command, like |
same issue for me. I'm using react native 0.64.2 react native reanimated 2.2.4. Tried multiple versions but all got me the same error: A problem occurred evaluating project ':react-native-reanimated'.
|
Confirm: this is still reproducing for anything above 2.2.0 with an official patch. Looks like it's only allowing a small subset of flavor names (those that are ending "Debug" and "Release"), which will completely crash for arbitrary naming system. Fixing regex did the trick, but the question is: should we force anyone who uses reanimated 2.2.0+ follow that naming convention for naming Android build flavours? I believe, no. Here is the patch I'm using:
|
Fixes #2412
Description
Fixed a build problem for Android users who have build flavors/variants:
Changes
Inside the function for
getCurrentFlavor()
the regex only matches against certain tasks:Added
bundle
to this to address the comment from @wbercx.Note that if this match fails, the current flavor is returned as empty string. However, if you have no flavors, this also returns an empty string. This presents a problem below in the logic because it can't determine between the two. Modified this to instead return
NOT-FOUND
which is not a valid Android product flavor.Since there are valid tasks (e.g. clean) that don't contain the current flavor, we don't want to execute the
merge
andstrip
tasks. So modified the if statement to ensure we only execute if there is a match. Again this is only a problem if you have flavors, since otherwise it can't the difference between an empty string match and non-match.Test code and steps to reproduce
See https://developer.android.com/studio/build/build-variants
Repro Steps:
app/build.gradle
(e.g. demo, full)./gradlew clean
(Alternatively, go to Android Studio > File > Sync Project with Gradle Files)
Checklist