You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Any Android React Native project which uses apply plugin: "com.android.library" currently fails to build. The problem is that a recent change (#20526) to react.gradle now uses android.applicationVariants when configuring the project. This is not present for library projects, so it fails.
Prior to this changes, Android library projects could be build successfully, so this is a regression.
This project is the generated content of react-native init SampleLibrary with the only change being modifying build.gradle to add apply plugin: "com.android.library"
You will see an error that looks something like this:
FAILURE: Build failed with an exception.
* Where:
Script '/Users/james/src/SampleLibrary/node_modules/react-native/react.gradle' line: 15
* What went wrong:
A problem occurred configuring project ':app'.
> Could not get unknown property 'applicationVariants' for object of type com.android.build.gradle.LibraryExtension.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
The text was updated successfully, but these errors were encountered:
…roid.library"` (facebook#22312)
Summary:
This PR allows Android projects that use `apply plugin: "com.android.library"` to build successfully. A recent regression caused by facebook#20526 means that building one of these projects always fails with this error:
```
FAILURE: Build failed with an exception.
* Where:
Script '/Users/james/src/SampleLibrary/node_modules/react-native/react.gradle' line: 15
* What went wrong:
A problem occurred configuring project ':app'.
> Could not get unknown property 'applicationVariants' for object of type com.android.build.gradle.LibraryExtension.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
```
This change updates `react.gradle` to cater to both application and library projects by selectively using `android.applicationVariants` or `android.libraryVariants`.
Fixesfacebook#22310.
Pull Request resolved: facebook#22312
Differential Revision: D13373742
Pulled By: cpojer
fbshipit-source-id: 64c35ab7a6d5d0d840a43729123e70dd8e0d36e0
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Environment
Run
react-native info
in your terminal and paste its contents here.Description
Any Android React Native project which uses
apply plugin: "com.android.library"
currently fails to build. The problem is that a recent change (#20526) toreact.gradle
now usesandroid.applicationVariants
when configuring the project. This is not present for library projects, so it fails.Prior to this changes, Android library projects could be build successfully, so this is a regression.
Reproducible Demo
I have put a simple project to demonstrate the issue here: https://github.com/jtreanor/sample-library-react-native.
This project is the generated content of
react-native init SampleLibrary
with the only change being modifyingbuild.gradle
to addapply plugin: "com.android.library"
The following steps will reproduce the error:
git clone git@github.com:jtreanor/sample-library-react-native.git
cd sample-library-react-native
yarn install
cd android && ./gradlew build
You will see an error that looks something like this:
The text was updated successfully, but these errors were encountered: