title: android, gradle and plugins
body: <p>Im trying to add onesignal to my gradle project. </p>
  
  <p>However I get the following error:</p>
  
  <pre><code>build file '/tmp/workspace/myapp-develop/My_app/android/app/build.gradle': 196: only buildscript {} and other plugins {} script blocks are allowed before plugins {} blocks, no other statements are allowed
  </code></pre>
  
  <p>My gradle app build.gradle file looks like:</p>
  
  <pre><code>apply plugin: "com.android.application"
  
  import com.android.build.OutputFile
  
  
  project.ext.react = [
      entryFile: "index.js"
  ]
  
  
  
  apply from: "../../node_modules/react-native/react.gradle"
  
  
  def enableSeparateBuildPerCPUArchitecture = false
  
  def enableProguardInReleaseBuilds = false
  
  configurations.all {
    resolutionStrategy.force 'com.google.android.gms:play-services-gcm:11.8.0'
    resolutionStrategy.force 'com.google.android.gms:play-services-analytics:11.8.0'
    resolutionStrategy.force 'com.google.android.gms:play-services-location:11.8.0'
    resolutionStrategy.force 'com.facebook.android:facebook-android-sdk:4.18.0'
  }
  
  android {
      compileSdkVersion 26
      buildToolsVersion "26.0.1"
  
      defaultConfig {
          applicationId "my.android.mobileapp"
          minSdkVersion 16
          targetSdkVersion 25
          versionCode 24
          versionName "0.0.24"
          ndk {
              abiFilters "armeabi-v7a", "x86"
          }
          manifestPlaceholders = [
              'onesignal_app_id': "xxxxx-xxxxx-xxx-xxxxx",
              'onesignal_google_project_number': "12345676789"
          ]
      }
      splits {
          abi {
              reset()
              enable enableSeparateBuildPerCPUArchitecture
              universalApk false  // If true, also generate a universal APK
              include "armeabi-v7a", "x86"
          }
      }
      buildTypes {
          release {
              minifyEnabled enableProguardInReleaseBuilds
              proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
          }
      }
      // applicationVariants are e.g. debug, release
      applicationVariants.all { variant -&gt;
          variant.outputs.each { output -&gt;
              // For each separate APK per architecture, set a unique version code as described here:
              // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
              def versionCodes = ["armeabi-v7a":1, "x86":2]
              def abi = output.getFilter(OutputFile.ABI)
              if (abi != null) {  // null for the universal-debug, universal-release variants
                  output.versionCodeOverride =
                          versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
              }
          }
      }
  }
  
  dependencies {
      compile project(':react-native-fabric')
      compile project(':react-native-spinkit')
      compile project(':react-native-push-notification')
      compile project(':react-native-google-analytics-bridge')
      compile project(':react-native-svg')
      compile project(':react-native-onesignal')
      compile fileTree(dir: "libs", include: ["*.jar"])
      compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
      compile "com.facebook.react:react-native:+"  // From node_modules
      compile project(':react-native-fabric')
      compile('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
        transitive = true;
      }
  }
  
  task copyDownloadableDepsToLibs(type: Copy) {
      from configurations.compile
      into 'libs'
  }
  
  buildscript {
    repositories {
      maven { url 'https://maven.fabric.io/public' }
    }    
        dependencies {
  changelog:
          // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
          classpath 'io.fabric.tools:gradle:1.+'
        }
      }
  
  
  apply plugin: 'io.fabric'
  
  plugins {
      id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.10.2' apply false 
  }
  
  repositories {
    maven { url 'https://maven.fabric.io/public' }
  }
  </code></pre>
  
  <p>I have tried:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/a/26240341/265119">https://stackoverflow.com/a/26240341/265119</a></li>
  <li>Putting the plugins declaration at the top of the file</li>
  </ul>
  
  <p>Neither of these has worked. </p>
  
  <p>Where exactly should I add the <code>plugin</code> statement?
  Also, is the <code>my_app/android/app/build.gradle</code> the correct file to add the <code>plugin</code> statement into?</p>