Skip to content

Commit b33941c

Browse files
committed
refactor: enhance Android build configuration for new architecture support
1 parent 0b1ed47 commit b33941c

1 file changed

Lines changed: 20 additions & 13 deletions

File tree

android/build.gradle

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
buildscript {
2-
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
3-
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["RNIterable_kotlinVersion"]
2+
ext.getExtOrDefault = {name ->
3+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['RNIterable_' + name]
4+
}
45

56
repositories {
67
google()
78
mavenCentral()
89
}
910

1011
dependencies {
11-
classpath "com.android.tools.build:gradle:7.2.1"
12+
classpath "com.android.tools.build:gradle:8.7.2"
1213
// noinspection DifferentKotlinGradleVersion
13-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
1415
}
1516
}
1617

17-
def reactNativeArchitectures() {
18-
def value = rootProject.getProperties().get("reactNativeArchitectures")
19-
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
20-
}
21-
2218
def isNewArchitectureEnabled() {
2319
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
2420
}
@@ -63,7 +59,11 @@ android {
6359
defaultConfig {
6460
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
6561
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
62+
buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
63+
}
6664

65+
buildFeatures {
66+
buildConfig true
6767
}
6868

6969
buildTypes {
@@ -80,6 +80,16 @@ android {
8080
sourceCompatibility JavaVersion.VERSION_1_8
8181
targetCompatibility JavaVersion.VERSION_1_8
8282
}
83+
84+
sourceSets {
85+
main {
86+
if (isNewArchitectureEnabled()) {
87+
java.srcDirs += ['src/newarch']
88+
} else {
89+
java.srcDirs += ['src/oldarch']
90+
}
91+
}
92+
}
8393
}
8494

8595
repositories {
@@ -90,10 +100,7 @@ repositories {
90100
def kotlin_version = getExtOrDefault("kotlinVersion")
91101

92102
dependencies {
93-
// For < 0.71, this will be from the local maven repo
94-
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
95-
//noinspection GradleDynamicVersion
96-
implementation "com.facebook.react:react-native:+"
103+
implementation "com.facebook.react:react-android"
97104
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
98105
api "com.iterable:iterableapi:3.5.2"
99106
// api project(":iterableapi") // links to local android SDK repo rather than by release

0 commit comments

Comments
 (0)