Skip to content

Custom prefab build for Android / v0.2.1 #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 2, 2024
Merged

Custom prefab build for Android / v0.2.1 #24

merged 6 commits into from
Sep 2, 2024

Conversation

rkistner
Copy link
Contributor

@rkistner rkistner commented Aug 22, 2024

When we just want to bundle the libpowersync.so files into the final .apk, the jniLibs approach works file. However, if we want to use the libs from another native Android library, such as with react-native-quick-sqlite, that approach is insufficient. Instead, we need Prefab for that.

The native Android tooling only supports building Prefab libraries using CMake or the NDK. Lucky for us, the Prefab format is very simple, and we can create a custom .aar file with the Prefab structure. We now completely avoid the android gradle plugin for generating the aar file.

The final .aar file will contain the following files:

AndroidManifest.xml
jni/arm64-v8a/libpowersync.so
jni/armeabi-v7a/libpowersync.so
jni/x86_64/libpowersync.so
jni/x86/libpowersync.so
META-INF/com/android/build/gradle/aar-metadata.properties
prefab/modules/powersync/include/powersync.h
prefab/modules/powersync/libs/android.arm64-v8a/abi.json
prefab/modules/powersync/libs/android.arm64-v8a/libpowersync.so
prefab/modules/powersync/libs/android.armeabi-v7a/abi.json
prefab/modules/powersync/libs/android.armeabi-v7a/libpowersync.so
prefab/modules/powersync/libs/android.x86_64/abi.json
prefab/modules/powersync/libs/android.x86_64/libpowersync.so
prefab/modules/powersync/libs/android.x86/abi.json
prefab/modules/powersync/libs/android.x86/libpowersync.so
prefab/modules/powersync/module.json
prefab/prefab.json

Usage in the consuming project:

// build.gradle
dependencies {
    implementation 'co.powersync:powersync-sqlite-core:0.2.0'
}
# CMakeLists.txt
find_package(powersync_sqlite_core REQUIRED CONFIG)

target_link_libraries(
  ${PACKAGE_NAME}
  # ...
  powersync_sqlite_core::powersync
)

The prefab folder is new, the rest were there before.

Note: prefab is only relevant when linking to this library via native code on Android. FFI or loading the extension via SQLite APIs does not need this.

@rkistner rkistner marked this pull request as ready for review August 29, 2024 08:33
@rkistner rkistner requested a review from mugikhan August 29, 2024 09:10
Copy link
Contributor

@stevensJourney stevensJourney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome to have prefab now. This will make the use in React Native Quick SQLite much nicer.

@rkistner rkistner mentioned this pull request Aug 29, 2024
12 tasks
Copy link
Contributor

@mugikhan mugikhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will make integration with other libraries such as op-sqlite in the future much easier!

@rkistner rkistner merged commit 4aeb732 into main Sep 2, 2024
40 checks passed
@rkistner rkistner deleted the android-prefab branch September 2, 2024 07:56
@rkistner rkistner changed the title Custom prefab build for Android Custom prefab build for Android / v0.2.1 Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants