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

Fix build error for Android projects that use apply plugin: "com.android.library" #22312

Closed
wants to merge 1 commit into from

Conversation

jtreanor
Copy link
Contributor

This PR allows Android projects that use apply plugin: "com.android.library" to build successfully. A recent regression caused by #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.

Fixes #22310.

Test Plan:

Build any Android project with apply plugin: "com.android.library" using ./gradlew build (I have a sample project here: https://github.com/jtreanor/sample-library-react-native). It will now succeed with these changes.

Changelog:

[Android] [Fixed] - Fixed build error with Android library projects

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 16, 2018
@pull-bot
Copy link

Warnings
⚠️

📋 Release Notes - This PR appears to be missing Release Notes.

Generated by 🚫 dangerJS

@react-native-bot react-native-bot added the Platform: Android Android applications. label Nov 16, 2018
@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Dec 7, 2018
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@cpojer
Copy link
Contributor

cpojer commented Dec 7, 2018

Thanks for the PR. This looks good to me.

@react-native-bot
Copy link
Collaborator

@jtreanor merged commit c090758 into facebook:master.

@facebook facebook locked as resolved and limited conversation to collaborators Dec 7, 2018
@react-native-bot react-native-bot added the Merged This PR has been merged. label Dec 7, 2018
@hramos hramos removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Feb 6, 2019
KusStar pushed a commit to KusStar/react-native that referenced this pull request Nov 11, 2020
…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`.

Fixes facebook#22310.
Pull Request resolved: facebook#22312

Differential Revision: D13373742

Pulled By: cpojer

fbshipit-source-id: 64c35ab7a6d5d0d840a43729123e70dd8e0d36e0
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Platform: Android Android applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants