Skip to content

Commit f859689

Browse files
committed
Introduce getRootExt for support of RN v0.56
1 parent 63d2e75 commit f859689

File tree

3 files changed

+85
-73
lines changed

3 files changed

+85
-73
lines changed

android/build.gradle

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
apply plugin: "com.android.library"
22

3+
4+
def getRootExt(name, fallback) {
5+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : fallback
6+
}
7+
38
android {
4-
compileSdkVersion 25
5-
buildToolsVersion "25.0.1"
9+
compileSdkVersion getRootExt("compileSdkVersion", 25)
10+
buildToolsVersion getRootExt("buildToolsVersion", "25.0.1")
611

7-
defaultConfig {
8-
minSdkVersion 16
9-
targetSdkVersion 23
10-
versionCode 1
11-
versionName "1.0"
12-
}
12+
defaultConfig {
13+
minSdkVersion 16
14+
targetSdkVersion getRootExt("targetSdkVersion", 23)
15+
versionCode 1
16+
versionName "1.0"
17+
}
1318
}
1419

1520
dependencies {
16-
compile "com.facebook.react:react-native:+" // From node_modules
17-
compile 'com.android.support:customtabs:25.0.1'
18-
compile ('com.github.droibit.customtabslauncher:launcher:1.0.8') {
19-
exclude module: 'customtabs'
20-
}
21+
compile "com.facebook.react:react-native:+" // From node_modules
22+
compile "com.android.support:customtabs:${getRootExt('supportLibVersion', '25.0.1')}"
23+
compile('com.github.droibit.customtabslauncher:launcher:1.0.8') {
24+
exclude module: 'customtabs'
25+
}
2126

22-
testCompile 'junit:junit:4.12'
27+
testCompile 'junit:junit:4.12'
2328
}

example/android/app/build.gradle

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -67,63 +67,61 @@ apply from: "../../node_modules/react-native/react.gradle"
6767
* - An APK that only works on x86 devices
6868
* The advantage is the size of the APK is reduced by about 4MB.
6969
* Upload all the APKs to the Play Store and people will download
70-
* the correct one based on the CPU architecture of their device.
71-
*/
70+
* the correct one based on the CPU architecture of their device.*/
7271
def enableSeparateBuildPerCPUArchitecture = false
7372

7473
/**
75-
* Run Proguard to shrink the Java bytecode in release builds.
76-
*/
74+
* Run Proguard to shrink the Java bytecode in release builds.*/
7775
def enableProguardInReleaseBuilds = false
7876

7977
android {
80-
compileSdkVersion 25
81-
buildToolsVersion "25.0.1"
78+
compileSdkVersion rootProject.compileSdkVersion
79+
buildToolsVersion rootProject.buildToolsVersion
8280

83-
defaultConfig {
84-
applicationId "com.github.droibit.android.reactnative.customtabs.example"
85-
minSdkVersion 16
86-
targetSdkVersion 23
87-
versionCode 1
88-
versionName "1.0"
89-
ndk {
90-
abiFilters "armeabi-v7a", "x86"
91-
}
81+
defaultConfig {
82+
applicationId "com.github.droibit.android.reactnative.customtabs.example"
83+
minSdkVersion 16
84+
targetSdkVersion rootProject.targetSdkVersion
85+
versionCode 1
86+
versionName "1.0"
87+
ndk {
88+
abiFilters "armeabi-v7a", "x86"
9289
}
93-
splits {
94-
abi {
95-
reset()
96-
enable enableSeparateBuildPerCPUArchitecture
97-
universalApk false // If true, also generate a universal APK
98-
include "armeabi-v7a", "x86"
99-
}
90+
}
91+
splits {
92+
abi {
93+
reset()
94+
enable enableSeparateBuildPerCPUArchitecture
95+
universalApk false // If true, also generate a universal APK
96+
include "armeabi-v7a", "x86"
10097
}
101-
buildTypes {
102-
release {
103-
minifyEnabled enableProguardInReleaseBuilds
104-
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
105-
}
98+
}
99+
buildTypes {
100+
release {
101+
minifyEnabled enableProguardInReleaseBuilds
102+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
106103
}
107-
// applicationVariants are e.g. debug, release
108-
applicationVariants.all { variant ->
109-
variant.outputs.each { output ->
110-
// For each separate APK per architecture, set a unique version code as described here:
111-
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
112-
def versionCodes = ["armeabi-v7a":1, "x86":2]
113-
def abi = output.getFilter(OutputFile.ABI)
114-
if (abi != null) { // null for the universal-debug, universal-release variants
115-
output.versionCodeOverride =
116-
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
117-
}
118-
}
104+
}
105+
// applicationVariants are e.g. debug, release
106+
applicationVariants.all { variant ->
107+
variant.outputs.each { output ->
108+
// For each separate APK per architecture, set a unique version code as described here:
109+
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
110+
def versionCodes = ["armeabi-v7a": 1, "x86": 2]
111+
def abi = output.getFilter(OutputFile.ABI)
112+
if (abi != null) {
113+
// null for the universal-debug, universal-release variants
114+
output.versionCodeOverride = versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
115+
}
119116
}
117+
}
120118
}
121119

122120
dependencies {
123-
compile fileTree(dir: "libs", include: ["*.jar"])
124-
compile project(':react-native-custom-tabs')
125-
compile "com.android.support:appcompat-v7:25.0.1"
126-
compile "com.facebook.react:react-native:+" // From node_modules
121+
compile fileTree(dir: "libs", include: ["*.jar"])
122+
compile project(':react-native-custom-tabs')
123+
compile "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
124+
compile "com.facebook.react:react-native:+" // From node_modules
127125
}
128126

129127
// Run this once to be able to run the application with BUCK

example/android/build.gradle

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
repositories {
5-
jcenter()
6-
}
7-
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.2.0'
4+
repositories {
5+
maven { url 'http://maven.google.com/' }
6+
jcenter()
7+
}
8+
dependencies {
9+
classpath 'com.android.tools.build:gradle:2.2.0'
910

10-
// NOTE: Do not place your application dependencies here; they belong
11-
// in the individual module build.gradle files
12-
}
11+
// NOTE: Do not place your application dependencies here; they belong
12+
// in the individual module build.gradle files
13+
}
1314
}
1415

1516
allprojects {
16-
repositories {
17-
mavenLocal()
18-
jcenter()
19-
maven {
20-
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
21-
url "$projectDir/../../node_modules/react-native/android"
22-
}
23-
maven { url "https://jitpack.io" }
17+
repositories {
18+
maven { url 'http://maven.google.com/' }
19+
mavenLocal()
20+
jcenter()
21+
maven {
22+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
23+
url "$projectDir/../../node_modules/react-native/android"
2424
}
25+
maven { url "https://jitpack.io" }
26+
}
27+
}
28+
29+
ext {
30+
buildToolsVersion = "25.0.1"
31+
compileSdkVersion = 25
32+
targetSdkVersion = 25
33+
supportLibVersion = "25.0.1"
2534
}

0 commit comments

Comments
 (0)