Skip to content

Commit 07267c1

Browse files
Merge remote-tracking branch 'origin/main' into grdb-drivers
2 parents 59408b0 + 4075302 commit 07267c1

File tree

11 files changed

+79
-125
lines changed

11 files changed

+79
-125
lines changed

.github/workflows/test.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,55 @@ jobs:
7474
path: |
7575
**/build/reports/
7676
**/build/test-results/
77+
78+
android_emulator:
79+
runs-on: ubuntu-latest
80+
timeout-minutes: 30
81+
env:
82+
AVD_NAME: ubuntu-avd-x86_64-31
83+
steps:
84+
- name: checkout
85+
uses: actions/checkout@v4
86+
87+
- name: Validate Gradle Wrapper
88+
uses: gradle/actions/wrapper-validation@v4
89+
- uses: actions/cache@v4
90+
with:
91+
path: ~/.konan
92+
key: ${{ runner.os }}-${{ hashFiles('**/.lock') }}
93+
- name: Set up JDK 17
94+
uses: actions/setup-java@v4
95+
with:
96+
java-version: '17'
97+
distribution: 'temurin'
98+
- name: Set up Gradle
99+
uses: gradle/actions/setup-gradle@v4
100+
with:
101+
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
102+
- name: AVD Cache
103+
uses: actions/cache@v4
104+
id: avd-cache
105+
with:
106+
path: |
107+
~/.android/avd/*
108+
~/.android/adb*
109+
key: avd-31
110+
111+
# https://github.com/ReactiveCircus/android-emulator-runner?tab=readme-ov-file#usage--examples
112+
- name: Enable KVM
113+
run: |
114+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
115+
sudo udevadm control --reload-rules
116+
sudo udevadm trigger --name-match=kvm
117+
118+
- name: emulator tests
119+
uses: reactivecircus/android-emulator-runner@v2
120+
with:
121+
api-level: 31
122+
force-avd-creation: false
123+
target: google_apis
124+
arch: x86_64
125+
disable-animations: false
126+
avd-name: $AVD_NAME
127+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
128+
script: ./gradlew --scan core-tests-android:connectedCheck

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.6.1
4+
5+
* Fix `dlopen failed: library "libpowersync.so.so" not found` errors on Android.
6+
37
## 1.6.0
48

59
* Remove internal SQLDelight and SQLiter dependencies.

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ and API documentation [here](https://powersync-ja.github.io/powersync-kotlin/).
3434
2. Apply local changes on your backend application server (and from there, to your backend database).
3535

3636
- [integrations](./integrations/)
37-
- [room](./integrations/room/README.md): Allows using the [Room database library](https://developer.android.com/jetpack/androidx/releases/room)
38-
with PowerSync, making it easier to run typed queries on the database.
37+
- [room](./integrations/room/README.md): Allows using the [Room database library](https://developer.android.com/jetpack/androidx/releases/room) with PowerSync, making it easier to run typed queries on the database.
3938
- [sqldelight](./integrations/sqldelight/README.md): Allows using [SQLDelight](https://sqldelight.github.io/sqldelight)
4039
with PowerSync, also enabling typed statements on the database.
4140

build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ dependencies {
7070
dokka(project(":core:"))
7171
dokka(project(":connectors:supabase"))
7272
dokka(project(":compose:"))
73+
dokka(project(":integrations:room"))
74+
dokka(project(":integrations:sqldelight"))
7375
}
7476

7577
dokka {
@@ -97,9 +99,11 @@ develocity {
9799
tasks.register("serveDokka") {
98100
group = "dokka"
99101
dependsOn("dokkaGenerate")
102+
val rootProvider = layout.buildDirectory.dir("dokka/html")
103+
100104
doLast {
105+
val root = rootProvider.get().asFile
101106
val server = HttpServer.create(InetSocketAddress(0), 0)
102-
val root = file("build/dokka/html")
103107

104108
val handler =
105109
com.sun.net.httpserver.HttpHandler { exchange: HttpExchange ->

core/build.gradle.kts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ kotlin {
171171
androidMain {
172172
dependsOn(commonJava)
173173
dependencies {
174+
api(libs.powersync.sqlite.core.android)
174175
implementation(libs.ktor.client.okhttp)
175176
implementation(libs.androidx.sqlite.bundled)
176177
}
@@ -255,11 +256,6 @@ android {
255256
consumerProguardFiles("proguard-rules.pro")
256257
}
257258

258-
sourceSets {
259-
getByName("main") {
260-
jniLibs.srcDirs("src/androidMain/jni", "src/main/jni", "src/jniLibs")
261-
}
262-
}
263259
ndkVersion = "27.1.12297006"
264260
}
265261

core/proguard-rules.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Temporary workaround for https://issuetracker.google.com/issues/442489402
2+
-keepclasseswithmembers class androidx.sqlite.driver.bundled.** { native <methods>; }

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ development=true
1919
RELEASE_SIGNING_ENABLED=true
2020
# Library config
2121
GROUP=com.powersync
22-
LIBRARY_VERSION=1.6.0
22+
LIBRARY_VERSION=1.6.1
2323
GITHUB_REPO=https://github.com/powersync-ja/powersync-kotlin.git
2424
# POM
2525
POM_URL=https://github.com/powersync-ja/powersync-kotlin/

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ compose = "1.8.2" # This is for the multiplatform compose
3030
androidCompose = "2025.08.00"
3131
compose-preview = "1.9.0"
3232
compose-lifecycle = "2.9.2"
33-
androidxSqlite = "2.6.0-rc02"
33+
androidxSqlite = "2.6.0"
3434
androidxSplashscreen = "1.0.1"
35-
room = "2.8.0-rc02"
35+
room = "2.8.0"
3636
sqldelight = "2.1.0"
3737

3838
# plugins

integrations/room/README.md

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,8 @@
11
# PowerSync Room integration
22

3-
This module provides the ability to use PowerSync with Room databases. This module aims for complete
4-
Room support, meaning that:
3+
> [!NOTE]
4+
> Note that this package is currently in alpha.
55
6-
1. Changes synced from PowerSync automatically update your Room `Flow`s.
7-
2. Room and PowerSync cooperate on the write connection, avoiding "database is locked errors".
8-
3. Changes from Room trigger a CRUD upload.
6+
This module integrates PowerSync with Room databases. This allows you run typed queries against the local database with compile-time validation.
97

10-
## Setup
11-
12-
Add a dependency on `com.powersync:integration-room` with the same version you use for the main
13-
PowerSync SDK.
14-
15-
PowerSync can use an existing Room database, provided that the PowerSync core SQLite extension has
16-
been loaded. To do that:
17-
18-
1. Add a dependency on `androidx.sqlite:sqlite-bundled`. Using the SQLite version from the Android
19-
framework will not work as it doesn't support loading extensions.
20-
2. On your `RoomDatabase.Builder`, call `setDriver()` with a PowerSync-enabled driver:
21-
```Kotlin
22-
val driver = BundledSQLiteDriver().also {
23-
it.loadPowerSyncExtension() // Extension method by this module
24-
}
25-
26-
Room.databaseBuilder(...).setDriver(driver).build()
27-
```
28-
3. Configure raw tables for your Room databases.
29-
30-
After these steps, you can open your Room database like you normally would. Then, you can use the
31-
following method to obtain a `PowerSyncDatabase` instance which is backed by Room:
32-
33-
```Kotlin
34-
// With Room, you need to use raw tables (https://docs.powersync.com/usage/use-case-examples/raw-tables).
35-
// This is because Room verifies your schema at runtime, and PowerSync-managed views will not
36-
// pass those checks.
37-
val schema = Schema(...)
38-
val pool = RoomConnectionPool(yourRoomDatabase, schema)
39-
val powersync = PowerSyncDatabase.opened(
40-
pool = pool,
41-
scope = this,
42-
schema = schema,
43-
identifier = "databaseName", // Prefer to use the same path/name as your Room database
44-
logger = Logger,
45-
)
46-
powersync.connect(...)
47-
```
48-
49-
Changes from PowerSync (regardless of whether they've been made with `powersync.execute` or from a
50-
sync operation) will automatically trigger updates in Room.
51-
52-
To also transfer local writes to PowerSync, you need to
53-
54-
1. Create triggers on your Room tables to insert into `ps_crud` (see the
55-
[PowerSync documentation on raw tables](https://docs.powersync.com/usage/use-case-examples/raw-tables#capture-local-writes-with-triggers)
56-
for details).
57-
2. Pass the schema as a second parameter to the `RoomConnectionPool` constructor. This will make the
58-
pool notify PowerSync on Room writes for every raw table mentioned in the schema.
59-
Alternatively, call `transferPendingRoomUpdatesToPowerSync` after writes in Room.
8+
For details on using this integration, see its page on the [PowerSync documentation](https://docs.powersync.com/client-sdk-references/kotlin-multiplatform/libraries/room).

integrations/sqldelight/README.md

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,8 @@
11
## PowerSync SQLDelight driver
22

3-
This library provides the `PowerSyncDriver` class, which implements an `SqlDriver` for `SQLDelight`
4-
backed by PowerSync.
3+
> [!NOTE]
4+
> Note that this package is currently in beta.
55
6-
## Setup
6+
This library integrates PowerSync with SQLDelight. This allows you run typed queries against the local database with compile-time validation. It provides the `PowerSyncDriver` class, which implements a `SqlDriver` for `SQLDelight` backed by PowerSync.
77

8-
Add a dependency on `com.powersync:integration-sqldelight`, using the same version you use for the
9-
PowerSync SDK.
10-
11-
## Usage
12-
13-
To get started, ensure that SQLDelight is not linking sqlite3 (the PowerSync SDK takes care of that,
14-
and you don't want to link it twice). Also, ensure the async generator is active because the
15-
PowerSync driver does not support synchronous reads:
16-
17-
```kotlin
18-
sqldelight {
19-
databases {
20-
linkSqlite.set(false)
21-
22-
create("MyAppDatabase") {
23-
generateAsync.set(true)
24-
deriveSchemaFromMigrations.set(false)
25-
26-
dialect("app.cash.sqldelight:sqlite-3-38-dialect")
27-
}
28-
}
29-
}
30-
```
31-
32-
Next, define your tables in `.sq` files (but note that the `CREATE TABLE` statement won't be used,
33-
PowerSync creates JSON-backed views for tables instead).
34-
Open a PowerSync database [in the usual way](https://docs.powersync.com/client-sdk-references/kotlin-multiplatform#getting-started)
35-
and finally pass it to the constructor of your generated SQLDelight database:
36-
37-
```kotlin
38-
val db: PowerSyncDatabase = openPowerSyncDatabase()
39-
val yourSqlDelightDatabase = YourDatabase(PowerSyncDriver(db))
40-
```
41-
42-
Afterwards, writes on both databases (the original `PowerSyncDatabase` instance and the SQLDelight
43-
database) will be visible to each other, update each other's query flows and will get synced
44-
properly.
45-
46-
## Limitations
47-
48-
Please note that this library is currently in alpha. It is tested, but API changes are still
49-
possible.
50-
51-
There are also some limitations to be aware of:
52-
53-
1. Due to historical reasons, the PowerSync SDK migrates all databases to `user_version` 1 when
54-
created (but it will never downgrade a database).
55-
So if you want to use SQLDelight's schema tools, the first version would have to be `2`.
56-
2. The `CREATE TABLE` statements in your `.sq` files are only used at build time to verify your
57-
queries. At runtime, PowerSync will create tables from your schema as views, the defined
58-
statements are ignored.
59-
If you want to use the schema managed by SQLDelight, configure PowerSync to use
60-
[raw tables](https://docs.powersync.com/usage/use-case-examples/raw-tables).
61-
3. Functions and tables contributed by the PowerSync core extension are not visible to `.sq` files
62-
at the moment. We might revisit this with a custom dialect in the future.
8+
For details on using this integration, see its page on the [PowerSync documentation](https://docs.powersync.com/client-sdk-references/kotlin-multiplatform/libraries/sqldelight).

0 commit comments

Comments
 (0)