RNdev
RNdev

Reputation: 1241

Do you add multiple buildscripts in `app/build.gradle` for manual Android linking in React Native?

In the section adding the gradle plugin for this React Native component, it tells me to add the following code to app/build.gradle:

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal 
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99]'
    }
}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

However, I've added other components that said to add similar code. For example, this component says to add this code:

buildscript {
  repositories {
    maven { url 'https://maven.fabric.io/public' }
  }
  dependencies {
    // The Fabric Gradle plugin uses an open ended version to react
    // quickly to Android tooling updates
    classpath 'io.fabric.tools:gradle:1.+'
  }
}
apply plugin: 'io.fabric'
repositories {
  maven { url 'https://maven.fabric.io/public' }
}

What I Want To Know:

How do you add the code for both of these components into the same project?

Upvotes: 0

Views: 562

Answers (1)

Fahad Alotaibi
Fahad Alotaibi

Reputation: 424

You should have one build script and add all the repositories in the repositories block and the dependences in the dependencies block

it should be like this

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal 
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99]'
        // The Fabric Gradle plugin uses an open ended version to react
        // quickly to Android tooling updates
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

for the apply plugins should be in the build.gradle for the app module add them on the top

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'io.fabric'
android {
 compileSdkVersion 28

 defaultConfig {
    applicationId "your.app.package"
  }
}

Upvotes: 1

Related Questions