Skip to content

Commit 5e48a25

Browse files
authored
fix: Support newer React Native versions (#10)
1 parent 61b02a7 commit 5e48a25

30 files changed

Lines changed: 2718 additions & 11299 deletions

apps/test-app/App.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import * as std from 'typegpu/std';
1818

1919
const t = tgpu;
2020

21-
const centerGravity: GravityFn = (args) => {
21+
const centerGravity: GravityFn = (pos) => {
2222
'kernel';
23-
return std.mul(2, d.vec2f(d.f32(-args.pos.x), d.f32(-args.pos.y)));
23+
return std.mul(2, d.vec2f(d.f32(-pos.x), d.f32(-pos.y)));
2424
};
2525

2626
const rightGravity: GravityFn = () => {
@@ -36,7 +36,7 @@ const strongGravity: GravityFn = () => {
3636
return d.vec2f(0, -3);
3737
};
3838

39-
const pointInitParticle: InitParticleFn = ({ index: i }) => {
39+
const pointInitParticle: InitParticleFn = (i) => {
4040
'kernel';
4141
particles.value[i].position = d.vec2f(
4242
(2 * randf.sample() - 1) / 2 / 50,
@@ -48,7 +48,7 @@ const pointInitParticle: InitParticleFn = ({ index: i }) => {
4848
);
4949
};
5050

51-
const twoSidesInitParticle: InitParticleFn = ({ index: i }) => {
51+
const twoSidesInitParticle: InitParticleFn = (i) => {
5252
'kernel';
5353

5454
if (i % 2 === 0) {
@@ -74,7 +74,7 @@ const twoSidesInitParticle: InitParticleFn = ({ index: i }) => {
7474
}
7575
};
7676

77-
const customGravity: GravityFn = ({ pos }) => {
77+
const customGravity: GravityFn = (pos) => {
7878
'kernel';
7979
return d.vec2f(-pos.x, -3);
8080
};

apps/test-app/android/app/build.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ react {
1414
hermesCommand = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc"
1515
codegenDir = new File(["node", "--print", "require.resolve('@react-native/codegen/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
1616

17+
enableBundleCompression = (findProperty('android.enableBundleCompression') ?: false).toBoolean()
1718
// Use Expo CLI to bundle the app, this ensures the Metro config
1819
// works correctly with Expo projects.
1920
cliFile = new File(["node", "--print", "require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })"].execute(null, rootDir).text.trim())
@@ -78,7 +79,7 @@ def enableProguardInReleaseBuilds = (findProperty('android.enableProguardInRelea
7879
* give correct results when using with locales other than en-US. Note that
7980
* this variant is about 6MiB larger per architecture than default.
8081
*/
81-
def jscFlavor = 'org.webkit:android-jsc:+'
82+
def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+'
8283

8384
android {
8485
ndkVersion rootProject.ext.ndkVersion
@@ -156,15 +157,15 @@ dependencies {
156157

157158
if (isGifEnabled) {
158159
// For animated gif support
159-
implementation("com.facebook.fresco:animated-gif:${reactAndroidLibs.versions.fresco.get()}")
160+
implementation("com.facebook.fresco:animated-gif:${expoLibs.versions.fresco.get()}")
160161
}
161162

162163
if (isWebpEnabled) {
163164
// For webp support
164-
implementation("com.facebook.fresco:webpsupport:${reactAndroidLibs.versions.fresco.get()}")
165+
implementation("com.facebook.fresco:webpsupport:${expoLibs.versions.fresco.get()}")
165166
if (isWebpAnimatedEnabled) {
166167
// Animated webp support
167-
implementation("com.facebook.fresco:animated-webp:${reactAndroidLibs.versions.fresco.get()}")
168+
implementation("com.facebook.fresco:animated-webp:${expoLibs.versions.fresco.get()}")
168169
}
169170
}
170171

apps/test-app/android/app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@
2020
<action android:name="android.intent.action.MAIN"/>
2121
<category android:name="android.intent.category.LAUNCHER"/>
2222
</intent-filter>
23-
<intent-filter>
24-
<action android:name="android.intent.action.VIEW"/>
25-
<category android:name="android.intent.category.DEFAULT"/>
26-
<category android:name="android.intent.category.BROWSABLE"/>
27-
<data android:scheme="com.anonymous.testapp"/>
28-
</intent-filter>
2923
</activity>
3024
</application>
3125
</manifest>

apps/test-app/android/app/src/main/java/com/anonymous/testapp/MainApplication.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class MainApplication : Application(), ReactApplication {
2424
override fun getPackages(): List<ReactPackage> {
2525
val packages = PackageList(this).packages
2626
// Packages that cannot be autolinked yet can be added manually here, for example:
27-
// packages.add(new MyReactNativePackage());
27+
// packages.add(MyReactNativePackage())
2828
return packages
2929
}
3030

apps/test-app/android/app/src/main/res/values/styles.xml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
<resources xmlns:tools="http://schemas.android.com/tools">
2-
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
3-
<item name="android:textColor">@android:color/black</item>
4-
<item name="android:editTextStyle">@style/ResetEditText</item>
2+
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
53
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
64
<item name="colorPrimary">@color/colorPrimary</item>
75
<item name="android:statusBarColor">#EFEFF9</item>
8-
</style>
9-
<style name="ResetEditText" parent="@android:style/Widget.EditText">
10-
<item name="android:padding">0dp</item>
11-
<item name="android:textColorHint">#c8c8c8</item>
12-
<item name="android:textColor">@android:color/black</item>
6+
<item name="android:windowOptOutEdgeToEdgeEnforcement" tools:targetApi="35">true</item>
137
</style>
148
<style name="Theme.App.SplashScreen" parent="AppTheme">
159
<item name="android:windowBackground">@drawable/ic_launcher_background</item>

apps/test-app/android/build.gradle

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,37 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext {
5-
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '35.0.0'
6-
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '24')
7-
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '35')
8-
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34')
9-
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.25'
10-
11-
ndkVersion = "26.1.10909125"
12-
}
13-
repositories {
14-
google()
15-
mavenCentral()
16-
}
17-
dependencies {
18-
classpath('com.android.tools.build:gradle')
19-
classpath('com.facebook.react:react-native-gradle-plugin')
20-
classpath('org.jetbrains.kotlin:kotlin-gradle-plugin')
21-
}
4+
repositories {
5+
google()
6+
mavenCentral()
7+
}
8+
dependencies {
9+
classpath('com.android.tools.build:gradle')
10+
classpath('com.facebook.react:react-native-gradle-plugin')
11+
classpath('org.jetbrains.kotlin:kotlin-gradle-plugin')
12+
}
2213
}
2314

24-
apply plugin: "com.facebook.react.rootproject"
15+
def reactNativeAndroidDir = new File(
16+
providers.exec {
17+
workingDir(rootDir)
18+
commandLine("node", "--print", "require.resolve('react-native/package.json')")
19+
}.standardOutput.asText.get().trim(),
20+
"../android"
21+
)
2522

2623
allprojects {
27-
repositories {
28-
maven {
29-
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
30-
url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))
31-
}
32-
maven {
33-
// Android JSC is installed from npm
34-
url(new File(['node', '--print', "require.resolve('jsc-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), '../dist'))
35-
}
36-
37-
google()
38-
mavenCentral()
39-
maven { url 'https://www.jitpack.io' }
24+
repositories {
25+
maven {
26+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
27+
url(reactNativeAndroidDir)
4028
}
29+
30+
google()
31+
mavenCentral()
32+
maven { url 'https://www.jitpack.io' }
33+
}
4134
}
35+
36+
apply plugin: "expo-root-project"
37+
apply plugin: "com.facebook.react.rootproject"

apps/test-app/android/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ EX_DEV_CLIENT_NETWORK_INSPECTOR=true
5454

5555
# Use legacy packaging to compress native libraries in the resulting APK.
5656
expo.useLegacyPackaging=false
57+
58+
# Whether the app is configured to use edge-to-edge via the app config or `react-native-edge-to-edge` plugin
59+
expo.edgeToEdgeEnabled=false

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

apps/test-app/android/gradlew

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,39 @@
11
pluginManagement {
2-
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().toString())
2+
def reactNativeGradlePlugin = new File(
3+
providers.exec {
4+
workingDir(rootDir)
5+
commandLine("node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })")
6+
}.standardOutput.asText.get().trim()
7+
).getParentFile().absolutePath
8+
includeBuild(reactNativeGradlePlugin)
9+
10+
def expoPluginsPath = new File(
11+
providers.exec {
12+
workingDir(rootDir)
13+
commandLine("node", "--print", "require.resolve('expo-modules-autolinking/package.json', { paths: [require.resolve('expo/package.json')] })")
14+
}.standardOutput.asText.get().trim(),
15+
"../android/expo-gradle-plugin"
16+
).absolutePath
17+
includeBuild(expoPluginsPath)
18+
}
19+
20+
plugins {
21+
id("com.facebook.react.settings")
22+
id("expo-autolinking-settings")
323
}
4-
plugins { id("com.facebook.react.settings") }
524

625
extensions.configure(com.facebook.react.ReactSettingsExtension) { ex ->
726
if (System.getenv('EXPO_USE_COMMUNITY_AUTOLINKING') == '1') {
827
ex.autolinkLibrariesFromCommand()
928
} 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)
29+
ex.autolinkLibrariesFromCommand(expoAutolinking.rnConfigCommand)
2130
}
2231
}
32+
expoAutolinking.useExpoModules()
2333

2434
rootProject.name = 'Confetti Test'
2535

26-
dependencyResolutionManagement {
27-
versionCatalogs {
28-
reactAndroidLibs {
29-
from(files(new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../gradle/libs.versions.toml")))
30-
}
31-
}
32-
}
33-
34-
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle");
35-
useExpoModules()
36+
expoAutolinking.useExpoVersionCatalog()
3637

3738
include ':app'
38-
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())
39+
includeBuild(expoAutolinking.reactNativeGradlePlugin)

0 commit comments

Comments
 (0)