Advertisement
nonameolsson

Untitled

Apr 18th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 7.32 KB | None | 0 0
  1. apply plugin: "com.android.application"
  2.  
  3. import com.android.build.OutputFile
  4.  
  5. /**
  6.  * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
  7.  * and bundleReleaseJsAndAssets).
  8.  * These basically call `react-native bundle` with the correct arguments during the Android build
  9.  * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
  10.  * bundle directly from the development server. Below you can see all the possible configurations
  11.  * and their defaults. If you decide to add a configuration block, make sure to add it before the
  12.  * `apply from: "../../node_modules/react-native/react.gradle"` line.
  13.  *
  14.  * project.ext.react = [
  15.  *   // the name of the generated asset file containing your JS bundle
  16.  *   bundleAssetName: "index.android.bundle",
  17.  *
  18.  *   // the entry file for bundle generation
  19.  *   entryFile: "index.android.js",
  20.  *
  21.  *   // whether to bundle JS and assets in debug mode
  22.  *   bundleInDebug: false,
  23.  *
  24.  *   // whether to bundle JS and assets in release mode
  25.  *   bundleInRelease: true,
  26.  *
  27.  *   // whether to bundle JS and assets in another build variant (if configured).
  28.  *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
  29.  *   // The configuration property can be in the following formats
  30.  *   //         'bundleIn${productFlavor}${buildType}'
  31.  *   //         'bundleIn${buildType}'
  32.  *   // bundleInFreeDebug: true,
  33.  *   // bundleInPaidRelease: true,
  34.  *   // bundleInBeta: true,
  35.  *
  36.  *   // the root of your project, i.e. where "package.json" lives
  37.  *   root: "../../",
  38.  *
  39.  *   // where to put the JS bundle asset in debug mode
  40.  *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
  41.  *
  42.  *   // where to put the JS bundle asset in release mode
  43.  *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
  44.  *
  45.  *   // where to put drawable resources / React Native assets, e.g. the ones you use via
  46.  *   // require('./image.png')), in debug mode
  47.  *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
  48.  *
  49.  *   // where to put drawable resources / React Native assets, e.g. the ones you use via
  50.  *   // require('./image.png')), in release mode
  51.  *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
  52.  *
  53.  *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
  54.  *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
  55.  *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
  56.  *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
  57.  *   // for example, you might want to remove it from here.
  58.  *   inputExcludes: ["android/**", "ios/**"],
  59.  *
  60.  *   // override which node gets called and with what additional arguments
  61.  *   nodeExecutableAndArgs: ["node"]
  62.  *
  63.  *   // supply additional arguments to the packager
  64.  *   extraPackagerArgs: []
  65.  * ]
  66.  */
  67.  
  68. apply from: "../../node_modules/react-native/react.gradle"
  69.  
  70. /**
  71.  * Set this to true to create two separate APKs instead of one:
  72.  *   - An APK that only works on ARM devices
  73.  *   - An APK that only works on x86 devices
  74.  * The advantage is the size of the APK is reduced by about 4MB.
  75.  * Upload all the APKs to the Play Store and people will download
  76.  * the correct one based on the CPU architecture of their device.
  77.  */
  78. def enableSeparateBuildPerCPUArchitecture = false
  79.  
  80. /**
  81.  * Run Proguard to shrink the Java bytecode in release builds.
  82.  */
  83. def enableProguardInReleaseBuilds = false
  84.  
  85. android {
  86.     compileSdkVersion 23
  87.     buildToolsVersion '23.0.1'
  88.  
  89.     defaultConfig {
  90.         applicationId "com.opusapp"
  91.         minSdkVersion 16
  92.         targetSdkVersion 22
  93.         versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch
  94.         versionName "${versionMajor}.${versionMinor}.${versionPatch}"
  95.         setProperty("archivesBaseName", "CDAB-Opus-$versionName")
  96.         ndk {
  97.             abiFilters "armeabi-v7a", "x86"
  98.         }
  99.         manifestPlaceholders = [onesignal_app_id: "263559c7-3e1b-4dc0-893a-26686f52cda8",
  100.             // Project number pulled from dashboard, local value is ignored.
  101.             onesignal_google_project_number: "REMOTE"]
  102.     }
  103.     signingConfigs {
  104.         release {
  105.             storeFile file(MYAPP_RELEASE_STORE_FILE)
  106.             storePassword MYAPP_RELEASE_STORE_PASSWORD
  107.             keyAlias MYAPP_RELEASE_KEY_ALIAS
  108.             keyPassword MYAPP_RELEASE_KEY_PASSWORD
  109.         }
  110.     }
  111.     splits {
  112.         abi {
  113.             reset()
  114.             enable enableSeparateBuildPerCPUArchitecture
  115.             universalApk false  // If true, also generate a universal APK
  116.             include "armeabi-v7a", "x86"
  117.         }
  118.     }
  119.     buildTypes {
  120.         release {
  121.             minifyEnabled enableProguardInReleaseBuilds
  122.             proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
  123.             signingConfig signingConfigs.release
  124.             fixNodeModules
  125.         }
  126.     }
  127.     // applicationVariants are e.g. debug, release
  128.     applicationVariants.all { variant ->
  129.         variant.outputs.each { output ->
  130.             // For each separate APK per architecture, set a unique version code as described here:
  131.             // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
  132.             def versionCodes = ["armeabi-v7a":1, "x86":2]
  133.             def abi = output.getFilter(OutputFile.ABI)
  134.             if (abi != null) {  // null for the universal-debug, universal-release variants
  135.                 output.versionCodeOverride =
  136.                         versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
  137.             }
  138.         }
  139.     }
  140. }
  141.  
  142. dependencies {
  143.     compile project(':react-native-onesignal')
  144.     compile project(':mobile-center-crashes')
  145.     compile project(':mobile-center-analytics')
  146.     compile project(':react-native-vector-icons')
  147.     compile fileTree(dir: "libs", include: ["*.jar"])
  148.     compile "com.android.support:appcompat-v7:23.0.1"
  149.     compile "com.facebook.react:react-native:+"  // From node_modules
  150.     compile 'com.onesignal:OneSignal:3.+@aar'
  151.    
  152.     // Required for OneSignal, even if you have added FCM.
  153.     compile 'com.google.android.gms:play-services-gcm:+'
  154.    
  155.     // Required for geotagging
  156.     compile "com.google.android.gms:play-services-location:+"
  157.    
  158.     // play-services-analytics is only needed when using 8.1.0 or older.
  159.     // compile 'com.google.android.gms:play-services-analytics:+'
  160. }
  161.  
  162. // Run this once to be able to run the application with BUCK
  163. // puts all compile dependencies into folder libs for BUCK to use
  164. task copyDownloadableDepsToLibs(type: Copy) {
  165.     from configurations.compile
  166.     into 'libs'
  167. }
  168.  
  169. void task fixNodeModules() {
  170.     exec {
  171.         println "Delete the `node_modules` folder"
  172.         workingDir = "${rootDir}/.."
  173.         executable "sh"
  174.         args "-c", "rm -rf node_modules"
  175.         println "Done!"
  176.     }
  177.     exec {
  178.         println "Install node modules"
  179.         workingDir "${rootDir}/.."
  180.         executable "sh"
  181.         args "-c", "npm install"
  182.         println "Done!"
  183.     }
  184.     exec {
  185.         println "Reset packager cache"
  186.         workingDir = System.env.TMPDIR
  187.         executable "sh"
  188.         args "-c", "rm -fr /react-*"
  189.         println "Done!"
  190.     }
  191. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement