Skip to content

Commit 8ff6076

Browse files
authored
Update Llama example to Fabric architecture (#36)
## Description Updated Llama example to new React Native architecture. ### Type of change - [x] Example Update ### Tested on - [x] iOS - [x] Android ### Checklist - [x] I have performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have updated the documentation accordingly - [x] My changes generate no new warnings
1 parent b61f500 commit 8ff6076

File tree

69 files changed

+2387
-3472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2387
-3472
lines changed

examples/llama/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ node_modules/
77
.expo/
88
dist/
99
web-build/
10+
expo-env.d.ts
1011

1112
# Native
1213
*.orig.*

examples/llama/android/app/build.gradle

+11-36
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,6 @@ apply plugin: "com.facebook.react"
44

55
def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath()
66

7-
static def versionToNumber(major, minor, patch) {
8-
return patch * 100 + minor * 10000 + major * 1000000
9-
}
10-
11-
def getRNVersion() {
12-
def version = providers.exec {
13-
workingDir(projectDir)
14-
commandLine("node", "-e", "console.log(require('react-native/package.json').version);")
15-
}.standardOutput.asText.get().trim()
16-
17-
def coreVersion = version.split("-")[0]
18-
def (major, minor, patch) = coreVersion.tokenize('.').collect { it.toInteger() }
19-
20-
return versionToNumber(
21-
major,
22-
minor,
23-
patch
24-
)
25-
}
26-
def rnVersion = getRNVersion()
27-
287
/**
298
* This is the configuration block to customize your React Native Android app.
309
* By default you don't need to apply any configuration, just uncomment the lines you need.
@@ -41,12 +20,12 @@ react {
4120
bundleCommand = "export:embed"
4221

4322
/* Folders */
44-
// The root of your project, i.e. where "package.json" lives. Default is '..'
45-
// root = file("../")
46-
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
47-
// reactNativeDir = file("../node_modules/react-native")
48-
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
49-
// codegenDir = file("../node_modules/@react-native/codegen")
23+
// The root of your project, i.e. where "package.json" lives. Default is '../..'
24+
// root = file("../../")
25+
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
26+
// reactNativeDir = file("../../node_modules/react-native")
27+
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
28+
// codegenDir = file("../../node_modules/@react-native/codegen")
5029

5130
/* Variants */
5231
// The list of variants to that are debuggable. For those we're going to
@@ -79,10 +58,8 @@ react {
7958
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
8059
// hermesFlags = ["-O", "-output-source-map"]
8160

82-
if (rnVersion >= versionToNumber(0, 75, 0)) {
83-
/* Autolinking */
84-
autolinkLibrariesWithApp()
85-
}
61+
/* Autolinking */
62+
autolinkLibrariesWithApp()
8663
}
8764

8865
/**
@@ -144,6 +121,9 @@ android {
144121
useLegacyPackaging (findProperty('expo.useLegacyPackaging')?.toBoolean() ?: false)
145122
}
146123
}
124+
androidResources {
125+
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~'
126+
}
147127
}
148128

149129
// Apply static values from `gradle.properties` to the `android.packagingOptions`
@@ -194,8 +174,3 @@ dependencies {
194174
implementation jscFlavor
195175
}
196176
}
197-
198-
if (rnVersion < versionToNumber(0, 75, 0)) {
199-
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
200-
applyNativeModulesAppBuildGradle(project)
201-
}

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<data android:scheme="https"/>
1212
</intent>
1313
</queries>
14-
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme">
14+
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:supportsRtl="true">
1515
<meta-data android:name="expo.modules.updates.ENABLED" android:value="false"/>
1616
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
1717
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
@@ -27,6 +27,5 @@
2727
<data android:scheme="com.anonymous.llama"/>
2828
</intent-filter>
2929
</activity>
30-
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/>
3130
</application>
3231
</manifest>

examples/llama/android/app/src/main/java/com/anonymous/llama/MainApplication.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.facebook.react.ReactPackage
1010
import com.facebook.react.ReactHost
1111
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
1212
import com.facebook.react.defaults.DefaultReactNativeHost
13+
import com.facebook.react.soloader.OpenSourceMergedSoMapping
1314
import com.facebook.soloader.SoLoader
1415

1516
import expo.modules.ApplicationLifecycleDispatcher
@@ -21,9 +22,10 @@ class MainApplication : Application(), ReactApplication {
2122
this,
2223
object : DefaultReactNativeHost(this) {
2324
override fun getPackages(): List<ReactPackage> {
25+
val packages = PackageList(this).packages
2426
// Packages that cannot be autolinked yet can be added manually here, for example:
2527
// packages.add(new MyReactNativePackage());
26-
return PackageList(this).packages
28+
return packages
2729
}
2830

2931
override fun getJSMainModuleName(): String = ".expo/.virtual-metro-entry"
@@ -40,7 +42,7 @@ class MainApplication : Application(), ReactApplication {
4042

4143
override fun onCreate() {
4244
super.onCreate()
43-
SoLoader.init(this, false)
45+
SoLoader.init(this, OpenSourceMergedSoMapping)
4446
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
4547
// If you opted-in for the New Architecture, we load the native entry point for this app.
4648
load()
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
22
<item android:drawable="@color/splashscreen_background"/>
3+
<item>
4+
<bitmap android:gravity="center" android:src="@drawable/splashscreen_logo"/>
5+
</item>
36
</layer-list>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

examples/llama/android/app/src/main/res/values/styles.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
<item name="android:textColor">@android:color/black</item>
1313
</style>
1414
<style name="Theme.App.SplashScreen" parent="AppTheme">
15-
<item name="android:windowBackground">@drawable/splashscreen</item>
15+
<item name="android:windowBackground">@drawable/ic_launcher_background</item>
1616
</style>
1717
</resources>

examples/llama/android/build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
buildscript {
44
ext {
5-
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '34.0.0'
6-
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23')
7-
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '34')
5+
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '35.0.0'
6+
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '24')
7+
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '35')
88
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34')
9-
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.23'
9+
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.24'
1010

1111
ndkVersion = "26.1.10909125"
1212
}

examples/llama/android/gradle.properties

+1-4
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
2222
# https://developer.android.com/topic/libraries/support-library/androidx-rn
2323
android.useAndroidX=true
2424

25-
# Automatically convert third-party libraries to use AndroidX
26-
android.enableJetifier=true
27-
2825
# Enable AAPT2 PNG crunching
2926
android.enablePngCrunchInReleaseBuilds=true
3027

@@ -38,7 +35,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
3835
# your application. You should enable this flag either if you want
3936
# to write custom TurboModules/Fabric components OR use libraries that
4037
# are providing them.
41-
newArchEnabled=false
38+
newArchEnabled=true
4239

4340
# Use this property to enable or disable the Hermes JS engine.
4441
# If set to false, you will be using JSC instead.
Binary file not shown.

examples/llama/android/gradle/wrapper/gradle-wrapper.properties

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

examples/llama/android/gradlew

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,8 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90+
' "$PWD" ) || exit
8891

8992
# Use the maximum available, or set MAX_FD != -1 to use that value.
9093
MAX_FD=maximum

examples/llama/android/gradlew.bat

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################

examples/llama/android/react-settings-plugin/build.gradle.kts

-19
This file was deleted.

examples/llama/android/react-settings-plugin/src/main/kotlin/expo/plugins/ReactSettingsPlugin.kt

-10
This file was deleted.
+16-44
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,23 @@
11
pluginManagement {
2-
def version = providers.exec {
3-
commandLine("node", "-e", "console.log(require('react-native/package.json').version);")
4-
}.standardOutput.asText.get().trim()
5-
def (_, reactNativeMinor, reactNativePatch) = version.split("-")[0].tokenize('.').collect { it.toInteger() }
6-
7-
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json')"].execute(null, rootDir).text.trim()).getParentFile().toString())
8-
if(reactNativeMinor == 74 && reactNativePatch <= 3){
9-
includeBuild("react-settings-plugin")
10-
}
2+
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json')"].execute(null, rootDir).text.trim()).getParentFile().toString())
113
}
12-
134
plugins { id("com.facebook.react.settings") }
145

15-
def getRNMinorVersion() {
16-
def version = providers.exec {
17-
commandLine("node", "-e", "console.log(require('react-native/package.json').version);")
18-
}.standardOutput.asText.get().trim()
19-
20-
def coreVersion = version.split("-")[0]
21-
def (major, minor, patch) = coreVersion.tokenize('.').collect { it.toInteger() }
22-
23-
return minor
24-
}
25-
26-
if (getRNMinorVersion() >= 75) {
27-
extensions.configure(com.facebook.react.ReactSettingsExtension) { ex ->
28-
if (System.getenv('EXPO_UNSTABLE_CORE_AUTOLINKING') == '1') {
29-
println('\u001B[32mUsing expo-modules-autolinking as core autolinking source\u001B[0m')
30-
def command = [
31-
'node',
32-
'--no-warnings',
33-
'--eval',
34-
'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))',
35-
'react-native-config',
36-
'--json',
37-
'--platform',
38-
'android'
39-
].toList()
40-
ex.autolinkLibrariesFromCommand(command)
41-
} else {
42-
ex.autolinkLibrariesFromCommand()
43-
}
6+
extensions.configure(com.facebook.react.ReactSettingsExtension) { ex ->
7+
if (System.getenv('EXPO_USE_COMMUNITY_AUTOLINKING') == '1') {
8+
ex.autolinkLibrariesFromCommand()
9+
} else {
10+
def command = [
11+
'node',
12+
'--no-warnings',
13+
'--eval',
14+
'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))',
15+
'react-native-config',
16+
'--json',
17+
'--platform',
18+
'android'
19+
].toList()
20+
ex.autolinkLibrariesFromCommand(command)
4421
}
4522
}
4623

@@ -57,10 +34,5 @@ dependencyResolutionManagement {
5734
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle");
5835
useExpoModules()
5936

60-
if (getRNMinorVersion() < 75) {
61-
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
62-
applyNativeModulesSettingsGradle(settings)
63-
}
64-
6537
include ':app'
6638
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile())

examples/llama/app.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
}
1818
]
1919
],
20+
"newArchEnabled": true,
2021
"splash": {
2122
"image": "./assets/icons/splash.png",
2223
"resizeMode": "contain",

examples/llama/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { registerRootComponent } from 'expo';
2+
3+
import App from './App';
4+
5+
// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
6+
// It also ensures that whether you load the app in Expo Go or in a native build,
7+
// the environment is set up appropriately
8+
registerRootComponent(App);

0 commit comments

Comments
 (0)