Skip to content

Commit 1245e82

Browse files
authored
Merge pull request #59 from powersync-ja/chore/update-android-minsdkversion
React native 0.76 compatibility
2 parents a05dae6 + 2804695 commit 1245e82

File tree

68 files changed

+4532
-4422
lines changed

Some content is hidden

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

68 files changed

+4532
-4422
lines changed

.changeset/weak-planes-joke.md

+5

android/CMakeLists.txt

+24-10
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,37 @@ set_target_properties(
5050
find_package(ReactAndroid REQUIRED CONFIG)
5151
find_package(fbjni REQUIRED CONFIG)
5252
find_package(powersync_sqlite_core REQUIRED CONFIG)
53-
find_library(LOG_LIB log)
54-
55-
if(${USE_HERMES})
56-
set(JSEXECUTOR_LIB ReactAndroid::hermes_executor)
57-
else()
58-
set(JSEXECUTOR_LIB ReactAndroid::jscexecutor)
59-
endif()
6053

54+
find_library(LOG_LIB log)
6155

6256
target_link_libraries(
6357
${PACKAGE_NAME}
6458
${LOG_LIB}
6559
fbjni::fbjni
6660
ReactAndroid::jsi
67-
ReactAndroid::turbomodulejsijni
68-
ReactAndroid::react_nativemodule_core
69-
${JSEXECUTOR_LIB}
7061
android
7162
powersync_sqlite_core::powersync
7263
)
64+
65+
# This if-then-else can be removed once this library does not support react-native versions below 0.76
66+
# Ideally we would just depend on `REACTNATIVE_MERGED_SO`
67+
# See https://github.com/react-native-community/discussions-and-proposals/discussions/816
68+
if(REACTNATIVE_MERGED_SO OR ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
69+
target_link_libraries(
70+
${PACKAGE_NAME}
71+
ReactAndroid::reactnative
72+
)
73+
else()
74+
if(${USE_HERMES})
75+
set(JSEXECUTOR_LIB ReactAndroid::hermes_executor)
76+
else()
77+
set(JSEXECUTOR_LIB ReactAndroid::jscexecutor)
78+
endif()
79+
80+
target_link_libraries(
81+
${PACKAGE_NAME}
82+
ReactAndroid::turbomodulejsijni
83+
ReactAndroid::react_nativemodule_core
84+
${JSEXECUTOR_LIB}
85+
)
86+
endif()

android/build.gradle

+6-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ repositories {
4747

4848
android {
4949

50+
namespace "com.reactnativequicksqlite"
5051
compileSdkVersion safeExtGet("compileSdkVersion", 28)
5152

5253
// Used to override the NDK path/version on internal CI or by allowing
@@ -67,7 +68,7 @@ android {
6768
}
6869

6970
defaultConfig {
70-
minSdkVersion 23
71+
minSdkVersion 24
7172
targetSdkVersion safeExtGet('targetSdkVersion', 28)
7273
versionCode 1
7374
versionName "1.0"
@@ -90,7 +91,10 @@ android {
9091
"META-INF/**",
9192
"**/libjsi.so",
9293
"**/libreact_nativemodule_core.so",
93-
"**/libturbomodulejsijni.so"
94+
"**/libturbomodulejsijni.so",
95+
"**/libreactnative.so",
96+
"**/libc++_shared.so",
97+
"**/libfbjni.so"
9498
]
9599
}
96100

android/src/main/AndroidManifest.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.reactnativequicksqlite">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
32

43
</manifest>

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@
5050
"devDependencies": {
5151
"@changesets/cli": "^2.26.2",
5252
"prettier": "^3.3.3",
53-
"react": "18.2.0",
54-
"react-native": "0.74.5",
53+
"react": "18.3.1",
54+
"react-native": "0.76.2",
5555
"react-native-builder-bob": "^0.30.1",
56-
"typescript": "^4.8.4"
56+
"typescript": "^5.3.3"
5757
},
5858
"peerDependencies": {
5959
"react": "*",

tests/.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,8 @@ yarn-error.*
3333

3434
# typescript
3535
*.tsbuildinfo
36+
37+
# Expo
38+
.expo
39+
dist/
40+
web-build/

tests/android/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ build/
1010
local.properties
1111
*.iml
1212
*.hprof
13+
.cxx/
1314

1415
# Bundle artifacts
1516
*.jsbundle

tests/android/app/build.gradle

+13-13
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ react {
2020
bundleCommand = "export:embed"
2121

2222
/* Folders */
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")
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")
2929

3030
/* Variants */
3131
// The list of variants to that are debuggable. For those we're going to
@@ -57,6 +57,9 @@ react {
5757
//
5858
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
5959
// hermesFlags = ["-O", "-output-source-map"]
60+
61+
/* Autolinking */
62+
autolinkLibrariesWithApp()
6063
}
6164

6265
/**
@@ -90,8 +93,6 @@ android {
9093
targetSdkVersion rootProject.ext.targetSdkVersion
9194
versionCode 1
9295
versionName "1.0.0"
93-
94-
buildConfigField("boolean", "REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS", (findProperty("reactNative.unstable_useRuntimeSchedulerAlways") ?: true).toString())
9596
}
9697
signingConfigs {
9798
debug {
@@ -112,13 +113,17 @@ android {
112113
shrinkResources (findProperty('android.enableShrinkResourcesInReleaseBuilds')?.toBoolean() ?: false)
113114
minifyEnabled enableProguardInReleaseBuilds
114115
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
116+
crunchPngs (findProperty('android.enablePngCrunchInReleaseBuilds')?.toBoolean() ?: true)
115117
}
116118
}
117119
packagingOptions {
118120
jniLibs {
119121
useLegacyPackaging (findProperty('expo.useLegacyPackaging')?.toBoolean() ?: false)
120122
}
121123
}
124+
androidResources {
125+
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~'
126+
}
122127
}
123128

124129
// Apply static values from `gradle.properties` to the `android.packagingOptions`
@@ -163,14 +168,9 @@ dependencies {
163168
}
164169
}
165170

166-
implementation("com.facebook.react:flipper-integration")
167-
168171
if (hermesEnabled.toBoolean()) {
169172
implementation("com.facebook.react:hermes-android")
170173
} else {
171174
implementation jscFlavor
172175
}
173176
}
174-
175-
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");
176-
applyNativeModulesAppBuildGradle(project)

tests/android/app/src/main/AndroidManifest.xml

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
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"/>
16-
<meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="50.0.0"/>
1716
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
1817
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
1918
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
@@ -28,6 +27,5 @@
2827
<data android:scheme="com.reactnativequicksqlite.tests"/>
2928
</intent-filter>
3029
</activity>
31-
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/>
3230
</application>
3331
</manifest>

tests/android/app/src/main/java/com/reactnativequicksqlite/tests/MainActivity.kt

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package com.reactnativequicksqlite.tests
2+
import expo.modules.splashscreen.SplashScreenManager
23

34
import android.os.Build
45
import android.os.Bundle
@@ -15,7 +16,10 @@ class MainActivity : ReactActivity() {
1516
// Set the theme to AppTheme BEFORE onCreate to support
1617
// coloring the background, status bar, and navigation bar.
1718
// This is required for expo-splash-screen.
18-
setTheme(R.style.AppTheme);
19+
// setTheme(R.style.AppTheme);
20+
// @generated begin expo-splashscreen - expo prebuild (DO NOT MODIFY) sync-f3ff59a738c56c9a6119210cb55f0b613eb8b6af
21+
SplashScreenManager.registerOnActivity(this)
22+
// @generated end expo-splashscreen
1923
super.onCreate(null)
2024
}
2125

tests/android/app/src/main/java/com/reactnativequicksqlite/tests/MainApplication.kt

+5-13
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@ package com.reactnativequicksqlite.tests
22

33
import android.app.Application
44
import android.content.res.Configuration
5-
import androidx.annotation.NonNull
65

76
import com.facebook.react.PackageList
87
import com.facebook.react.ReactApplication
98
import com.facebook.react.ReactNativeHost
109
import com.facebook.react.ReactPackage
1110
import com.facebook.react.ReactHost
12-
import com.facebook.react.config.ReactFeatureFlags
1311
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
14-
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
1512
import com.facebook.react.defaults.DefaultReactNativeHost
16-
import com.facebook.react.flipper.ReactNativeFlipper
13+
import com.facebook.react.soloader.OpenSourceMergedSoMapping
1714
import com.facebook.soloader.SoLoader
1815

1916
import expo.modules.ApplicationLifecycleDispatcher
@@ -25,9 +22,10 @@ class MainApplication : Application(), ReactApplication {
2522
this,
2623
object : DefaultReactNativeHost(this) {
2724
override fun getPackages(): List<ReactPackage> {
25+
val packages = PackageList(this).packages
2826
// Packages that cannot be autolinked yet can be added manually here, for example:
2927
// packages.add(new MyReactNativePackage());
30-
return PackageList(this).packages
28+
return packages
3129
}
3230

3331
override fun getJSMainModuleName(): String = ".expo/.virtual-metro-entry"
@@ -40,21 +38,15 @@ class MainApplication : Application(), ReactApplication {
4038
)
4139

4240
override val reactHost: ReactHost
43-
get() = getDefaultReactHost(this.applicationContext, reactNativeHost)
41+
get() = ReactNativeHostWrapper.createReactHost(applicationContext, reactNativeHost)
4442

4543
override fun onCreate() {
4644
super.onCreate()
47-
SoLoader.init(this, false)
48-
if (!BuildConfig.REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS) {
49-
ReactFeatureFlags.unstable_useRuntimeSchedulerAlways = false
50-
}
45+
SoLoader.init(this, OpenSourceMergedSoMapping)
5146
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
5247
// If you opted-in for the New Architecture, we load the native entry point for this app.
5348
load()
5449
}
55-
if (BuildConfig.DEBUG) {
56-
ReactNativeFlipper.initializeFlipper(this, reactNativeHost.reactInstanceManager)
57-
}
5850
ApplicationLifecycleDispatcher.onApplicationCreate(this)
5951
}
6052

Binary file not shown.
Binary file not shown.
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>

tests/android/app/src/main/res/drawable/rn_edit_text_material.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
android:insetLeft="@dimen/abc_edit_text_inset_horizontal_material"
1818
android:insetRight="@dimen/abc_edit_text_inset_horizontal_material"
1919
android:insetTop="@dimen/abc_edit_text_inset_top_material"
20-
android:insetBottom="@dimen/abc_edit_text_inset_bottom_material">
20+
android:insetBottom="@dimen/abc_edit_text_inset_bottom_material"
21+
>
2122

2223
<selector>
2324
<!--
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.

tests/android/app/src/main/res/values/styles.xml

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
<item name="android:editTextStyle">@style/ResetEditText</item>
55
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
66
<item name="colorPrimary">@color/colorPrimary</item>
7-
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
7+
<item name="android:statusBarColor">#ffffff</item>
88
</style>
99
<style name="ResetEditText" parent="@android:style/Widget.EditText">
1010
<item name="android:padding">0dp</item>
1111
<item name="android:textColorHint">#c8c8c8</item>
1212
<item name="android:textColor">@android:color/black</item>
1313
</style>
14-
<style name="Theme.App.SplashScreen" parent="AppTheme">
15-
<item name="android:windowBackground">@drawable/splashscreen</item>
14+
<style name="Theme.App.SplashScreen" parent="Theme.SplashScreen">
15+
<item name="windowSplashScreenBackground">@color/splashscreen_background</item>
16+
<item name="windowSplashScreenAnimatedIcon">@drawable/splashscreen_logo</item>
17+
<item name="postSplashScreenTheme">@style/AppTheme</item>
1618
</style>
1719
</resources>

tests/android/build.gradle

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
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.8.10'
9+
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.24'
1010

11-
ndkVersion = "25.1.8937393"
11+
ndkVersion = "26.1.10909125"
1212
}
1313
repositories {
1414
google()
@@ -17,6 +17,7 @@ buildscript {
1717
dependencies {
1818
classpath('com.android.tools.build:gradle')
1919
classpath('com.facebook.react:react-native-gradle-plugin')
20+
classpath('org.jetbrains.kotlin:kotlin-gradle-plugin')
2021
}
2122
}
2223

tests/android/gradle.properties

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ 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
25+
# Enable AAPT2 PNG crunching
26+
android.enablePngCrunchInReleaseBuilds=true
2727

2828
# Use this property to specify which architecture you want to build.
2929
# You can also override it from the CLI using
@@ -54,3 +54,5 @@ 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+
android.extraMavenRepos=[]
-19.7 KB
Binary file not shown.

tests/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.3-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

0 commit comments

Comments
 (0)