Skip to content
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

Support 16 KB page sizes #1021

Open
xavierserrai opened this issue Jul 19, 2024 · 10 comments
Open

Support 16 KB page sizes #1021

xavierserrai opened this issue Jul 19, 2024 · 10 comments

Comments

@xavierserrai
Copy link

Dears,

Beginning with Android 15, Android supports devices that are configured to use a page size of 16 KB (16 KB devices).

https://developer.android.com/guide/practices/page-sizes#other-build-systems

I have tested this plugin with an Android 15 emulator that uses 16KB page sizes and when creating a database app crashes giving the following error:

FATAL EXCEPTION: pool-10-thread-3
Process: <PROCESS NAME>, PID: 12109
java.lang.UnsatisfiedLinkError: dlopen failed: empty/missing DT_HASH/DT_GNU_HASH in "/data/app/~~f4HklBgA8FB4x-ytaY2XqA==/<APP NAME>-ltZeoe99ImEJ3PBAJKzLow==/base.apk!/lib/arm64-v8a/libsqlc-ndk-native-driver.so" (new hash type from the future?)
at java.lang.Runtime.loadLibrary0(Runtime.java:1081)
at java.lang.Runtime.loadLibrary0(Runtime.java:1003)
at java.lang.System.loadLibrary(System.java:1765)
at io.liteglue.SQLiteConnector.<init>(SQLiteConnector.java:8)
at io.sqlc.SQLiteConnectorDatabase.<clinit>(SQLiteConnectorDatabase.java:35)
at io.sqlc.SQLitePlugin.openDatabase(SQLitePlugin.java:212)
at io.sqlc.SQLitePlugin.access$000(SQLitePlugin.java:28)
at io.sqlc.SQLitePlugin$DBRunner.run(SQLitePlugin.java:328)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)

libsqlc-ndk-native-driver.so might need to be recompiled to support 16KB page sizes.

Thanks,

@brodycj brodycj self-assigned this Jul 19, 2024
@brodycj brodycj pinned this issue Jul 19, 2024
@hooliapps
Copy link

hooliapps commented Jul 22, 2024

Hello

I have the same demand.

I use the plugin in my major apps: cordova-sqlite-ext

I also use the following plugin on other app:
cordova-sqlite-legacy-build-support

Hello, for info I did a small analysis of the concerned libraries.

  • Norman Breau: "I think the main thing that needs to be done for plugin authors is to use NDK 27 with a compiler flag and release a new binary. The new binary will be backwards compatible to 4kb devices but will also support and be optimised for new 16kb devices that will be coming."
  1. Plugin cordova-sqlite-legacy-build-support 1.3.5
    Library in analysed APK: lib/arm64-v8a/libsqlc-native-driver.so
    Dependencies in plugin.xml:







  2. Plugin cordova-sqlite-ext 6.0.0
    Library in analysed APK: lib/arm64-v8a/libsqlc-ndk-native.driver.so
    Dependencies in package.json:
    "dependencies": {
    "cordova-sqlite-ext-deps": "4.0.0"
    }

     In Plugin cordova-sqlite-ext-deps
     libs/
     	sqlite-native-ndk-connector.jar
     	sqlite-ndk-native-driver.jar
     Documentation:
     	sqlite3.h, sqlite3.c - SQLite 3.32.3 amalgamation needed to build iOS/macOS and Windows platform versions
     	libb64-core, sqlite3-base64, and sqlite3-regexp-cached source for iOS/macOS/Windows platform versions
     	libs - JAR libraries built from brodybits/android-sqlite-ndk-native-driver and brodybits/android-sqlite-native-ndk-connector, built with SQLite 3.32.3 amalgamation
    

@xavierserrai
Copy link
Author

Any updates on this?

@brodycj

@hooliapps
Copy link

Hello

Here some infos/hints to help to correct the problem.

I found this depot who seems to generate the .so libs
https://github.com/brodycj/Android-sqlite-ext-native-driver/blob/master/jni/Android.mk

Some doc: https://developer.android.com/guide/practices/page-sizes
"If your app uses any native code, then you should rebuild your app with support for 16 KB devices."

With NDK 26 at minimum, it seems one of the following flags must be added:
ndk-build: LOCAL_LDFLAGS += "-Wl,-z,max-page-size=16384"
CMake: target_link_options(${CMAKE_PROJECT_NAME} PRIVATE "-Wl,-z,max-page-size=16384")

@hooliapps
Copy link

Additional infos, i recompiled the Libs (thanks to Norman B.).

Libs are not tested currently.

"I followed your exemple, i did not "make init", but i executed ndk-build. Libs are created, 4 systems just armeabi is missing, i analysed the ELF files, there are some differences with your build (I used NDK 26.1) but i see 0x4000 :clin_d'œil: I will do some tests with the New Libs.

Sans titre

@hooliapps
Copy link

Hello, tested with Pixel 8 With Android 15 QR1 + Page Size 16Kb Mode.

App don't works and are not downloadable from Google Play also.

@hooliapps
Copy link

Logs from google play store:
did a adb log, and seems related... 08-24 19:59:25.598 3358 3358 E Finsky : [2] tpg.d(22): Submitter: commit error message INSTALL_FAILED_INVALID_APK: INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2

20 h 02
08-24 19:59:25.584 1350 1692 E NativeLibraryHelper: Library 'libsqlc-ndk-native-driver.so' is not PAGE(16384)-aligned - will not be able to open it directly from apk.

@NityaSantosh26
Copy link

I cloned https://github.com/brodycj/android-sqlite-ndk-native-driver and made changes to Application.mk as specified in Android documentation: https://developer.android.com/guide/practices/page-sizes#compile-r27-higher
Used ndk 27 and build the repository and using "make", Executed "make Makefile" which generated the jar file from the .so files.
Replaced the jar that this plugin uses from cordova-sqlite-storage-dependencies and built the app.
App launches in Android 15 Emulator. Verified sqlite db functionality and it works.

Raised a PR on brodycj/android-sqlite-ndk-native-driver#10
Waiting for the author @brodycj to re-build the project.

@hooliapps
Copy link

Thanks for your commit.

I advice you also test on real AAB Bu dle on Google Play. Because i had the following problem, recompilation seems not enough.

If not works, you will need to do that on your Main app.

In your Cordova app, you must add the following code in /app/build.gradle, under android { block:
packagingOptions {
jniLibs {
useLegacyPackaging = true
}
}

@NityaSantosh26
Copy link

@hooliapps, Thanks for the suggestion. You're correct, I couldn't install the app from play store (Bundle AAB). Adding the line provided in app/build.gradle fixed the installation.
This means AGP version also needs to be updated to 8.5 or above as mentioned in Android documentation?
https://developer.android.com/guide/practices/page-sizes#update-packaging

@NityaSantosh26
Copy link

@brodycj , Any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants