11buildscript {
2- ext {
3- kotlinVersion = ' 1.6.0'
4- buildToolsVersion = ' 29.0.2'
5- compileSdkVersion = 29
6- targetSdkVersion = 29
7- minSdkVersion = 18
8- }
9- ext. detoxKotlinVersion = ext. kotlinVersion
2+ def kotlinVersion = rootProject. ext. has(" kotlinVersion" ) ? rootProject. ext. get(" kotlinVersion" ) : project. properties[" RNBGU_kotlinVersion" ]
3+ ext. detoxKotlinVersion = kotlinVersion
104
115 repositories {
12- mavenCentral()
136 google()
7+ mavenCentral()
148 }
159 dependencies {
16- classpath ' com.android.tools.build:gradle:3.5.3 '
10+ classpath " com.android.tools.build:gradle:7.4.2 "
1711 classpath " org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion "
1812 }
1913}
2014
2115apply plugin : ' com.android.library'
2216apply plugin : ' kotlin-android'
23- apply plugin : ' kotlin-android-extensions'
2417
25- def DEFAULT_COMPILE_SDK_VERSION = 28
26- def DEFAULT_BUILD_TOOLS_VERSION = " 28.0.3 "
27- def DEFAULT_TARGET_SDK_VERSION = 28
18+ def getExtOrDefault ( name ) {
19+ return rootProject . ext . has(name) ? rootProject . ext . get(name) : project . properties[ " RNBGU_ " + name]
20+ }
2821
29- def safeExtGet ( prop , fallback ) {
30- rootProject. ext. has(prop ) ? rootProject. ext. get(prop ) : fallback
22+ def getExtOrIntegerDefault ( name ) {
23+ return rootProject. ext. has(name ) ? rootProject. ext. get(name ) : (project . properties[ " RNBGU_ " + name]) . toInteger()
3124}
3225
3326android {
34- compileSdkVersion safeExtGet(' compileSdkVersion' , DEFAULT_COMPILE_SDK_VERSION )
35- buildToolsVersion safeExtGet(' buildToolsVersion' , DEFAULT_BUILD_TOOLS_VERSION )
27+ compileSdkVersion getExtOrIntegerDefault(" compileSdkVersion" )
3628
3729 defaultConfig {
38- minSdkVersion 21
39- targetSdkVersion safeExtGet(' targetSdkVersion' , DEFAULT_TARGET_SDK_VERSION )
40- versionCode 1
41- versionName " 1.0"
42- ndk {
43- abiFilters " armeabi-v7a" , " x86"
44- }
30+ minSdkVersion getExtOrIntegerDefault(" minSdkVersion" )
31+ targetSdkVersion getExtOrIntegerDefault(" targetSdkVersion" )
4532 }
33+
4634 lintOptions {
4735 abortOnError false
4836 }
4937}
5038
5139repositories {
40+ google()
5241 mavenCentral()
53- }
5442
55- def _ext = ext
43+ def found = false
44+ def defaultDir = null
45+ def androidSourcesName = " React Native sources"
5646
57- def _kotlinVersion = _ext. has(' detoxKotlinVersion' ) ? _ext. detoxKotlinVersion : ' 1.3.10'
58- def _kotlinStdlib = _ext. has(' detoxKotlinStdlib' ) ? _ext. detoxKotlinStdlib : ' kotlin-stdlib-jdk8'
47+ if (rootProject. ext. has(" reactNativeAndroidRoot" )) {
48+ defaultDir = rootProject. ext. get(" reactNativeAndroidRoot" )
49+ } else {
50+ defaultDir = new File (
51+ projectDir,
52+ " /../../../node_modules/react-native/android"
53+ )
54+ }
5955
60- dependencies {
61- implementation " androidx.core:core-ktx:1.0.1"
56+ if (defaultDir. exists()) {
57+ maven {
58+ url defaultDir. toString()
59+ name androidSourcesName
60+ }
61+
62+ logger. info(" :${ project.name} :reactNativeAndroidRoot ${ defaultDir.canonicalPath} " )
63+ found = true
64+ } else {
65+ def parentDir = rootProject. projectDir
66+
67+ 1. upto(5 , {
68+ if (found) return true
69+ parentDir = parentDir. parentFile
6270
63- implementation ' com.facebook.react:react-native:+'
71+ def androidSourcesDir = new File (
72+ parentDir,
73+ " node_modules/react-native"
74+ )
6475
65- implementation " org.jetbrains.kotlin:$_kotlinStdlib :$_kotlinVersion "
76+ def androidPrebuiltBinaryDir = new File (
77+ parentDir,
78+ " node_modules/react-native/android"
79+ )
6680
67- implementation ' net.gotev:uploadservice-okhttp:4.7.0'
81+ if (androidPrebuiltBinaryDir. exists()) {
82+ maven {
83+ url androidPrebuiltBinaryDir. toString()
84+ name androidSourcesName
85+ }
6886
69- implementation ' androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
87+ logger. info(" :${ project.name} :reactNativeAndroidRoot ${ androidPrebuiltBinaryDir.canonicalPath} " )
88+ found = true
89+ } else if (androidSourcesDir. exists()) {
90+ maven {
91+ url androidSourcesDir. toString()
92+ name androidSourcesName
93+ }
94+
95+ logger. info(" :${ project.name} :reactNativeAndroidRoot ${ androidSourcesDir.canonicalPath} " )
96+ found = true
97+ }
98+ })
99+ }
100+
101+ if (! found) {
102+ throw new GradleException (
103+ " ${ project.name} : unable to locate React Native android sources. " +
104+ " Ensure you have you installed React Native as a dependency in your project and try again."
105+ )
106+ }
70107}
108+
109+ def kotlinVersion = getExtOrDefault(" kotlinVersion" )
110+
111+ dependencies {
112+ implementation " androidx.core:core-ktx:1.12.0"
113+
114+ implementation " com.facebook.react:react-native:+"
115+
116+ implementation " org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion "
117+
118+ implementation ' net.gotev:uploadservice-okhttp:4.9.2'
119+
120+ implementation ' androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
121+ }
0 commit comments