Skip to content

Commit a0c94cb

Browse files
imSzukalaclaude
andcommitted
build(example): upgrade example app from React Native 0.74 to 0.81
Upgrade the example app to React Native 0.81.1 to support modern Gradle (9.0.0) and compileSdk 36, which are required for the upcoming Intercom Android SDK 18.0.0 upgrade. Key changes: - React 18 → 19, React Native 0.74 → 0.81.1 - Convert MainActivity and MainApplication from Java to Kotlin - Adopt RN 0.81 Gradle autolinking pattern (settings.gradle) - Enable Hermes JS engine, remove Flipper - Gradle 8.7 → 9.0.0, versionless AGP, Kotlin 2.1.20, NDK 27 - Update iOS Podfile to RN 0.81 conventions with fmt Xcode 26 workaround - minSdkVersion 23 → 24 (required by RN 0.81) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3652aa4 commit a0c94cb

18 files changed

Lines changed: 2207 additions & 2176 deletions

File tree

examples/example/android/app/build.gradle

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ def isFoss = taskRequests.contains("foss")
1313
*/
1414
react {
1515
/* Folders */
16-
// The root of your project, i.e. where "package.json" lives. Default is '..'
17-
// root = file("../")
18-
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
19-
// reactNativeDir = file("../node_modules/react-native")
20-
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
21-
// codegenDir = file("../node_modules/@react-native/codegen")
22-
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
23-
// cliFile = file("../node_modules/react-native/cli.js")
16+
// The root of your project, i.e. where "package.json" lives. Default is '../..'
17+
// root = file("../../")
18+
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
19+
// reactNativeDir = file("../../node_modules/react-native")
20+
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
21+
// codegenDir = file("../../node_modules/@react-native/codegen")
22+
// The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
23+
// cliFile = file("../../node_modules/react-native/cli.js")
2424

2525
/* Variants */
2626
// The list of variants to that are debuggable. For those we're going to
@@ -54,6 +54,9 @@ react {
5454
//
5555
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
5656
// hermesFlags = ["-O", "-output-source-map"]
57+
58+
/* Autolinking */
59+
autolinkLibrariesWithApp()
5760
}
5861

5962
/**
@@ -65,14 +68,14 @@ def enableProguardInReleaseBuilds = false
6568
* The preferred build flavor of JavaScriptCore (JSC)
6669
*
6770
* For example, to use the international variant, you can use:
68-
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
71+
* `def jscFlavor = io.github.react-native-community:jsc-android-intl:2026004.+`
6972
*
7073
* The international variant includes ICU i18n library and necessary data
7174
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
7275
* give correct results when using with locales other than en-US. Note that
7376
* this variant is about 6MiB larger per architecture than default.
7477
*/
75-
def jscFlavor = 'org.webkit:android-jsc:+'
78+
def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+'
7679

7780
android {
7881
ndkVersion rootProject.ext.ndkVersion
@@ -113,8 +116,6 @@ android {
113116
dependencies {
114117
// The version of react-native is set by the React Native Gradle Plugin
115118
implementation("com.facebook.react:react-android")
116-
//implementation("com.facebook.react:flipper-integration")
117-
118119

119120
implementation 'com.google.firebase:firebase-messaging:20.2.+'
120121

@@ -126,5 +127,3 @@ dependencies {
126127

127128
implementation project(':intercomreactnative')
128129
}
129-
130-
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

examples/example/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
xmlns:tools="http://schemas.android.com/tools"
3-
package="com.example.intercomreactnative">
2+
xmlns:tools="http://schemas.android.com/tools">
43

54
<uses-permission android:name="android.permission.INTERNET" />
65

examples/example/android/app/src/main/java/com/example/intercomreactnative/MainActivity.java

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.example.intercomreactnative
2+
3+
import android.os.Bundle
4+
import android.content.Intent
5+
6+
import com.facebook.react.ReactActivity
7+
import com.facebook.react.ReactActivityDelegate
8+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
9+
import com.facebook.react.defaults.DefaultReactActivityDelegate
10+
11+
class MainActivity : ReactActivity() {
12+
13+
override fun onCreate(savedInstanceState: Bundle?) {
14+
super.onCreate(null)
15+
}
16+
17+
/**
18+
* Returns the name of the main component registered from JavaScript. This is used to schedule
19+
* rendering of the component.
20+
*/
21+
override fun getMainComponentName(): String = "IntercomReactNativeExample"
22+
23+
/**
24+
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
25+
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
26+
*/
27+
override fun createReactActivityDelegate(): ReactActivityDelegate =
28+
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
29+
30+
/**
31+
* This method is called when a new intent is received while the activity is running.
32+
* It needs to be added if your app needs to handle deep links opened through push notifications.
33+
*/
34+
override fun onNewIntent(intent: Intent) {
35+
super.onNewIntent(intent)
36+
setIntent(intent)
37+
}
38+
}

examples/example/android/app/src/main/java/com/example/intercomreactnative/MainApplication.java

Lines changed: 0 additions & 89 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.example.intercomreactnative
2+
3+
import android.app.Application
4+
import com.facebook.react.PackageList
5+
import com.facebook.react.ReactApplication
6+
import com.facebook.react.ReactHost
7+
import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
8+
import com.facebook.react.ReactNativeHost
9+
import com.facebook.react.ReactPackage
10+
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
11+
import com.facebook.react.defaults.DefaultReactNativeHost
12+
import com.intercom.reactnative.IntercomModule
13+
import com.intercom.reactnative.IntercomPackage
14+
15+
class MainApplication : Application(), ReactApplication {
16+
17+
override val reactNativeHost: ReactNativeHost =
18+
object : DefaultReactNativeHost(this) {
19+
override fun getPackages(): List<ReactPackage> =
20+
PackageList(this).packages.apply {
21+
// Packages that cannot be autolinked yet can be added manually here:
22+
add(IntercomPackage())
23+
}
24+
25+
override fun getJSMainModuleName(): String = "index"
26+
27+
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
28+
29+
override val isNewArchEnabled: Boolean = true
30+
override val isHermesEnabled: Boolean = true
31+
}
32+
33+
override val reactHost: ReactHost
34+
get() = getDefaultReactHost(applicationContext, reactNativeHost)
35+
36+
override fun onCreate() {
37+
super.onCreate()
38+
loadReactNative(this)
39+
40+
val appId = BuildConfig.ANDROID_INTERCOM_APP_ID
41+
val key = BuildConfig.ANDROID_INTERCOM_KEY
42+
IntercomModule.initialize(this, key, appId)
43+
}
44+
}

examples/example/android/build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
buildscript {
22
ext {
3-
buildToolsVersion = "35.0.0"
4-
minSdkVersion = 23
5-
compileSdkVersion = 35
6-
targetSdkVersion = 35
7-
ndkVersion = "26.1.10909125"
8-
kotlinVersion = "1.9.22"
3+
buildToolsVersion = "36.0.0"
4+
minSdkVersion = 24
5+
compileSdkVersion = 36
6+
targetSdkVersion = 36
7+
ndkVersion = "27.1.12297006"
8+
kotlinVersion = "2.1.20"
99
}
1010
repositories {
1111
google()
1212
mavenCentral()
1313
}
1414
dependencies {
15-
classpath("com.android.tools.build:gradle:8.6.1")
15+
classpath("com.android.tools.build:gradle")
1616
classpath("com.facebook.react:react-native-gradle-plugin")
1717
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
1818
}

examples/example/android/gradle.properties

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
# Specifies the JVM arguments used for the daemon process.
1111
# The setting is particularly useful for tweaking memory settings.
12-
# Default value: -Xmx10248m -XX:MaxPermSize=256m
13-
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
12+
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
13+
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
1414

1515
# When configured, Gradle will run in incubating parallel mode.
1616
# This option should only be used with decoupled projects. More details, visit
@@ -21,26 +21,24 @@
2121
# Android operating system, and which are packaged with your app's APK
2222
# https://developer.android.com/topic/libraries/support-library/androidx-rn
2323
android.useAndroidX=true
24-
# Automatically convert third-party libraries to use AndroidX
25-
android.enableJetifier=true
2624

2725
# Use this property to specify which architecture you want to build.
2826
# You can also override it from the CLI using
2927
# ./gradlew <task> -PreactNativeArchitectures=x86_64
3028
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
29+
3130
# Use this property to enable support to the new architecture.
3231
# This will allow you to use TurboModules and the Fabric render in
3332
# your application. You should enable this flag either if you want
3433
# to write custom TurboModules/Fabric components OR use libraries that
3534
# are providing them.
3635
newArchEnabled=false
37-
FLIPPER_VERSION=0.93.0
38-
android.suppressUnsupportedCompileSdk=35
3936

40-
org.gradle.jvmargs=-Xmx2048m
41-
org.gradle.daemon=true
42-
org.gradle.parallel=true
43-
org.gradle.configureondemand=true
4437
# Use this property to enable or disable the Hermes JS engine.
4538
# If set to false, you will be using JSC instead.
46-
hermesEnabled=false
39+
hermesEnabled=true
40+
41+
# Use this property to enable edge-to-edge display support.
42+
# This allows your app to draw behind system bars for an immersive UI.
43+
# Note: Only works with ReactActivity and should not be used with custom Activity.
44+
edgeToEdgeEnabled=false

examples/example/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.7-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

examples/example/android/settings.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
2+
plugins { id("com.facebook.react.settings") }
3+
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
14
rootProject.name = 'IntercomReactNativeExample'
2-
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
35
include ':app'
46
includeBuild('../node_modules/@react-native/gradle-plugin')
57

0 commit comments

Comments
 (0)