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.gradle setup #69

Merged
merged 2 commits into from
Sep 19, 2019
Merged

Conversation

friederbluemle
Copy link
Contributor

@friederbluemle friederbluemle commented Sep 18, 2019

Summary

Opening the android folder in Android Studio (or attempting to build it on command line) results in the following error:

ERROR: Plugin with id 'com.android.library' not found.

The reason was a missing buildscripts section in android/build.gradle. However, since the Android Gradle plugin is only required when opening the project stand-alone, the dependency was wrapped in a conditional:

if (project == rootProject) {
    // ... (dependency here)
}

By doing this, the project opens correctly in Android Studio, and it can also be consumed as a native module dependency from an application project without affecting the app project (avoiding unnecessary downloads/conflicts/etc).

A couple of other dependency fixes were required as well: com.facebook.react:react-native:+ is supposed to be included and resolved from a local path in node_modules. Therefore it needs to be added to the devDependencies section of the project. Without it, Gradle would pick the latest version of React Native from Maven Central: 0.20.1 from Feb 2016 😱.

Test Plan

What's required for testing (prerequisites)?

Android Studio and/or Gradle installed locally.

What are the steps to reproduce (after prerequisites)?

Open android in Android Studio:

$ studio android/

Or:

Generate a Gradle wrapper on the fly, and build on command line:

cd android/
gradle wrapper --gradle-version 5.4.1 --distribution-type all
./gradlew build

Successfully verified and tested on:

  • Android Device (Xiaomi Mi A2)
  • Android Emulator (Pixel 3a)
  • iOS Device (iPhone 8)
  • iOS Simulator (iPhone X)

Compatibility

OS Implemented
iOS
Android

Checklist

  • I have tested this on a device and a simulator
  • I added the documentation in README.md (N/A)
  • I mentioned this change in CHANGELOG.md (N/A)
  • I updated the typed files (TS and Flow) (N/A)
  • I added a sample use of the API in the example project (example/App.js) (N/A)

@zoontek
Copy link
Owner

zoontek commented Sep 19, 2019

@friederbluemle Thanks, I didn't know about this 👌🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants