// 宣告這是一隻 application
apply plugin: "com.android.application"
import com.android.build.OutputFile
// 由 React Native 處獲得其他設定
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
// 要編譯的目標 Android SDK 版本
compileSdkVersion 23
// 對應的 build tool 版本
buildToolsVersion "23.0.1"
// APK 資訊
defaultConfig {
// APK 的 APP ID
applicationId "com.myrn"
// 最低對應的 Android SDK 版本
minSdkVersion 16
// 目標版本
targetSdkVersion 22
// Android 版本號碼
versionCode 1
// Android 版本名稱
versionName "1.0"
// 以上這兩個對應組合起來會是 -> 1.0(1)
// NDK 香菇參數
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
// Android APK 的編譯模式
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// 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(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
// 相依套件
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}