Skip to content

Commit 3b0b26b

Browse files
committed
chore: update Android Gradle configurations and dependencies for improved compatibility
1 parent b70f0a7 commit 3b0b26b

10 files changed

Lines changed: 625 additions & 736 deletions

File tree

android/build.gradle

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
buildscript {
22
// 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"]
3+
// def kotlin_version = rootProject.ext.has("kotlinVersion") ?
4+
// rootProject.ext.get("kotlinVersion") :
5+
// project.properties["RNIterable_kotlinVersion"]
6+
ext.getExtOrDefault = {name ->
7+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['RNIterable_' + name]
8+
}
49

510
repositories {
611
google()
712
mavenCentral()
813
}
914

1015
dependencies {
11-
classpath "com.android.tools.build:gradle:7.2.1"
16+
classpath "com.android.tools.build:gradle:8.7.2"
1217
// noinspection DifferentKotlinGradleVersion
13-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
18+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
1419
}
1520
}
1621

22+
apply plugin: "com.android.library"
23+
apply plugin: "kotlin-android"
24+
25+
apply plugin: "com.facebook.react"
26+
27+
def getExtOrIntegerDefault(name) {
28+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNIterable_" + name]).toInteger()
29+
}
30+
1731
def reactNativeArchitectures() {
1832
def value = rootProject.getProperties().get("reactNativeArchitectures")
1933
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
@@ -34,10 +48,6 @@ def getExtOrDefault(name) {
3448
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["RNIterable_" + name]
3549
}
3650

37-
def getExtOrIntegerDefault(name) {
38-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNIterable_" + name]).toInteger()
39-
}
40-
4151
def supportsNamespace() {
4252
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
4353
def major = parsed[0].toInteger()
@@ -54,6 +64,10 @@ android {
5464
sourceSets {
5565
main {
5666
manifest.srcFile "src/main/AndroidManifestNew.xml"
67+
java.srcDirs += [
68+
"generated/java",
69+
"generated/jni"
70+
]
5771
}
5872
}
5973
}
@@ -63,7 +77,10 @@ android {
6377
defaultConfig {
6478
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
6579
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
80+
}
6681

82+
buildFeatures {
83+
buildConfig true
6784
}
6885

6986
buildTypes {
@@ -93,9 +110,16 @@ dependencies {
93110
// For < 0.71, this will be from the local maven repo
94111
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
95112
//noinspection GradleDynamicVersion
96-
implementation "com.facebook.react:react-native:+"
113+
implementation "com.facebook.react:react-android"
114+
// implementation "com.facebook.react:react-native:+"
97115
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
98116
api "com.iterable:iterableapi:3.5.2"
99117
// api project(":iterableapi") // links to local android SDK repo rather than by release
100118
}
101119

120+
react {
121+
jsRootDir = file("../src/")
122+
libraryName = "RNIterable"
123+
codegenJavaPackageName = "com.iterable.reactnative"
124+
}
125+

android/gradle.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
RNIterable_kotlinVersion=1.7.0
2-
RNIterable_minSdkVersion=21
3-
RNIterable_targetSdkVersion=31
4-
RNIterable_compileSdkVersion=31
5-
RNIterable_ndkversion=21.4.7075529
1+
RNIterable_kotlinVersion=2.0.21
2+
RNIterable_minSdkVersion=24
3+
RNIterable_targetSdkVersion=34
4+
RNIterable_compileSdkVersion=35
5+
RNIterable_ndkversion=27.1.12297006
66
android.useAndroidX=true
77
android.enableJetifier=true

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

example/android/app/build.gradle

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ def enableProguardInReleaseBuilds = false
6363
* The preferred build flavor of JavaScriptCore (JSC)
6464
*
6565
* For example, to use the international variant, you can use:
66-
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
66+
* `def jscFlavor = io.github.react-native-community:jsc-android-intl:2026004.+`
6767
*
6868
* The international variant includes ICU i18n library and necessary data
6969
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
7070
* give correct results when using with locales other than en-US. Note that
7171
* this variant is about 6MiB larger per architecture than default.
7272
*/
73-
def jscFlavor = 'org.webkit:android-jsc:+'
73+
def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+'
7474

7575
android {
7676
ndkVersion rootProject.ext.ndkVersion
@@ -85,6 +85,33 @@ android {
8585
versionCode 1
8686
versionName "1.0"
8787
}
88+
89+
packagingOptions {
90+
pickFirst '**/libc++_shared.so'
91+
pickFirst '**/libfbjni.so'
92+
pickFirst '**/libreact_featureflagsjni.so'
93+
exclude 'META-INF/DEPENDENCIES'
94+
exclude 'META-INF/LICENSE'
95+
exclude 'META-INF/LICENSE.txt'
96+
exclude 'META-INF/license.txt'
97+
exclude 'META-INF/NOTICE'
98+
exclude 'META-INF/NOTICE.txt'
99+
exclude 'META-INF/notice.txt'
100+
exclude 'META-INF/ASL2.0'
101+
}
102+
103+
bundle {
104+
language {
105+
enableSplit = false
106+
}
107+
density {
108+
enableSplit = false
109+
}
110+
abi {
111+
enableSplit = true
112+
}
113+
}
114+
88115
signingConfigs {
89116
debug {
90117
storeFile file('debug.keystore')

example/android/app/src/main/java/iterable/reactnativesdk/example/MainActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ class MainActivity : ReactActivity() {
2727
* This being in Kotlin **may** cause issues with react-native-screens
2828
*/
2929
override fun onCreate(savedInstanceState: Bundle?) {
30-
super.onCreate(null)
30+
super.onCreate(savedInstanceState)
3131
}
32-
}
32+
}

example/android/build.gradle

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ buildscript {
22
ext {
33
buildToolsVersion = "35.0.0"
44
minSdkVersion = 24
5-
compileSdkVersion = 34
6-
targetSdkVersion = 34
7-
ndkVersion = "26.1.10909125"
8-
kotlinVersion = "1.7.20"
5+
compileSdkVersion = 35
6+
targetSdkVersion = 35
7+
ndkVersion = "27.1.12297006"
8+
kotlinVersion = "2.0.21"
99
}
1010
repositories {
1111
google()
1212
mavenCentral()
1313
}
1414
dependencies {
15-
classpath('com.android.tools.build:gradle:8.7.2')
16-
classpath("com.facebook.react:react-native-gradle-plugin")
17-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
15+
classpath("com.android.tools.build:gradle:8.2.2")
16+
classpath("com.facebook.react:react-native-gradle-plugin:0.79.2")
17+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
1818
}
1919
}
2020

@@ -24,5 +24,13 @@ allprojects {
2424
repositories {
2525
google()
2626
mavenCentral()
27+
maven {
28+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
29+
url("$rootDir/../node_modules/react-native/android")
30+
}
31+
maven {
32+
// Android JSC is installed from npm
33+
url("$rootDir/../node_modules/jsc-android/dist")
34+
}
2735
}
2836
}

example/android/gradle.properties

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
1515
# When configured, Gradle will run in incubating parallel mode.
1616
# This option should only be used with decoupled projects. More details, visit
1717
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18-
# org.gradle.parallel=true
18+
org.gradle.parallel=true
19+
org.gradle.configureondemand=true
20+
org.gradle.daemon=true
21+
org.gradle.caching=true
1922

2023
# AndroidX package structure to make it clearer which packages are bundled with the
2124
# Android operating system, and which are packaged with your app's APK
@@ -40,4 +43,11 @@ hermesEnabled=true
4043

4144
# Needed for react-native-webview
4245
# See: https://github.com/react-native-webview/react-native-webview/blob/HEAD/docs/Getting-Started.md
43-
android.enableJetifier=true
46+
android.enableJetifier=true
47+
48+
# Enable R8 full mode
49+
android.enableR8.fullMode=true
50+
51+
# Enable dynamic feature support
52+
android.dynamicFeatures=base
53+
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
distributionBase=GRADLE_USER_HOME
2-
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
4-
networkTimeout=10000
5-
validateDistributionUrl=true
6-
zipStoreBase=GRADLE_USER_HOME
7-
zipStorePath=wrapper/dists
1+
distributionBase = GRADLE_USER_HOME
2+
distributionPath = wrapper/dists
3+
distributionUrl = https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
4+
networkTimeout = 10000
5+
validateDistributionUrl = true
6+
zipStoreBase = GRADLE_USER_HOME
7+
zipStorePath = wrapper/dists

example/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616
"@react-navigation/stack": "^6.4.1",
1717
"react": "19.0.0",
1818
"react-native": "0.79.2",
19-
"react-native-gesture-handler": "^2.20.1",
19+
"react-native-gesture-handler": "^2.25.0",
20+
"react-native-gradle-plugin": "^0.71.19",
21+
"react-native-is-edge-to-edge": "^1.1.7",
2022
"react-native-safe-area-context": "^5.4.1",
21-
"react-native-screens": "^3.34.0",
23+
"react-native-screens": "^4.11.1",
2224
"react-native-vector-icons": "^10.2.0",
2325
"react-native-webview": "^13.13.5"
2426
},
2527
"devDependencies": {
2628
"@babel/core": "^7.25.2",
27-
"@babel/preset-env": "^7.25.9",
29+
"@babel/preset-env": "^7.25.3",
2830
"@babel/runtime": "^7.25.0",
2931
"@react-native-community/cli": "18.0.0",
3032
"@react-native-community/cli-platform-android": "18.0.0",

0 commit comments

Comments
 (0)