apply plugin: 'com.android.application'

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

android {
    compileSdkVersion 24
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.walmartlabs.ern"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        ndk {
           abiFilters "armeabi-v7a", "x86"
       }
    }
    splits {
       abi {
           reset()
           enable enableSeparateBuildPerCPUArchitecture
           universalApk false  // If true, also generate a universal APK
           include "armeabi-v7a", "x86"
       }
   }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    // Need this to avoid build conflict with jsr version which comes with react-native
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.0'
    }
    // Needs this for okio issue (should be more restrictive to only okio)
    lintOptions {
        disable 'InvalidPackage'
    }
    // applicationVariants are e.g. debug, release
   applicationVariants.all { variant ->
       variant.outputs.each { output ->
           // 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(com.android.build.OutputFile.ABI)
           if (abi != null) {  // null for the universal-debug, universal-release variants
               output.versionCodeOverride =
                       versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
           }
       }
   }
}

dependencies {
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    testCompile 'junit:junit:4.12'

    // Recompile this dependency on every build as it can be updated at any time (snapshot)
    compile('com.walmartlabs.ern:runner-ern-container:1.0.0') { changing = true }
}
