Hello,
Setting the target android SDK value to 30 results in the (normally working fine) plugin to fail when opening the database.
"OPEN database: _ionicstorage FAILED, aborting any pending transactions"
If I set the SDK value to < 30, it suddenly starts working again.
Cordova: 10
Android: 9
Ionic Storage: 2.3.1
Cordova SQLite Storage: 5.1.0
Thanks
@brodybits sorry to tag directly, but do you have any idea what could be causing this? I've noticed if I provide androidDatabaseProvider: 'system', it begins to work again however I'm using Ionic Storage and don't have that level of control / flexibility. I've also tried to go direct and use the SQLite plugin and bypass the Ionic Storage code, but the data that was once stored in SQLite no longer exists, I'm assuming because a different provider is used...
I am also facing the same issue on Android 11 (Api 30) however it works fine for (API 29).
Here is my analysis:
following code returns negative int value
SQLiteNative.sqlc_db_open(this.dbfilename, this.openflags)
in file
https://github.com/liteglue/Android-sqlite-connector/blob/master/src/io/liteglue/SQLGDatabaseHandle.java
_Line 14_
Due to which https://github.com/liteglue/Android-sqlite-connector/blob/master/src/io/liteglue/SQLiteGlueConnection.java
line 12 throws Error.
It's the same issue reported here: https://github.com/storesafe/cordova-sqlite-storage-dependencies/issues/3
The plugin is not working as expected on Android 11 devices.
Thanks for reporting, I will investigate this in the near future. I will also investigate if this is an issue in cordova-sqlcipher-adapter, which is always using a custom SQLCipher build also based on SQLite.
@brodybits @jfrumar Has this issue been addressed? We are also seeing the same problem. Thanks!
Hi. Same here. Is there work planned on this ? Given the merged fork at https://github.com/OutSystems/Android-sqlite-native-driver/pull/1 + the sqlcipher investigation above.
Thanks
@brodybits
Thanks for the ping, I will definitely work on this with high priority. Please ping me if you do not see progress in the next 2-3 weeks.
I tried Android SDK 30 together with Android 11 from this branch of cordova-sqlite-test-app: https://github.com/brodybits/cordova-sqlite-test-app/tree/android-sdk-30-test
I am able to use the buttons to add record and show record count still with no problems on an Android 11 emulator. I may need a some time to obtain an Android 11 device for further testing.
"OPEN database: _ionicstorage FAILED, aborting any pending transactions"
This error indicates to me that the app opens a database and immediately starts one or more transactions. I recommend that you consider waiting for the openDatabase success callback as documented.
Hey!
I'm hoping I can chip in with some useful info but take this with a pinch of salt as I've not sanity checked this.
When setting the targetSDK to 30 as the author mentions it would fail to open the database on Android 11. It wouldn't happen on all devices though. We saw it on the latest generation of Pixels most notably so the 4A, 4A (5G) and 5.
We tried the Pixel 4 & 3A and they worked fine. All devices tested were on A11.
Sorry I know that's probably not much use but hopefully helps a little ๐
I can confirm that setting the Target API to 29 does indeed solve the problem. Using the callback does not - it will in fact call the error callback, though it is still best practices to do this anyway and I'd recommend implementing it this way when possible.
I'm not sure what actually triggers it though as indeed, I tested on numerous Android 11 devices with no issue except it fails on the Galaxy S20+.
I have the same problem.
DB error occurs on Pixcel 4a (android11). If it is a simulator, no error will occur.
Since August 2021, google has required SDK30 support. So I don't think it's very good to lower the sdk version.
https://developer.android.com/distribute/best-practices/develop/target-sdk
I can confirm that the issue also happens on the Samsung S21 Ultra 5G and the Xiaomi Mi Note 10. I'd love to avoid lowering the target SDK if in any way possible.
@brodybits
Also having the same problem, just by initializing the DB and read some data.
Everythinkg worked fine before SDK30 / Android 11.
I am able to use the buttons to add record and show record count still with no problems on an Android 11 emulator. I may need a some time to obtain an Android 11 device for further testing.
You could use 30 Mintues for free at https://www.browserstack.com using a real remote device. You just need to upload the APK and can choose between lots of real devices. For OpenSource projects like yours, you can ask for the OpenSource program to get a free full lifetime access:
https://www.browserstack.com/open-source
I tried a lot these days, also to reproduce the bug in your test app.
After a long time trying and getting crazy, I have found the problem: There was a typo in your test app.
I created a PR https://github.com/brodybits/cordova-sqlite-test-app/pull/7 and hope you can fix the problem soon, as i really do not want to drop your plugin from my project as i have to create a new release of my app soon.
Maybe you can work together or be inspired by the guys of
https://github.com/OutSystems/Cordova-sqlite-storage/pull/7
https://github.com/OutSystems/Cordova-sqlite-storage/pull/8
https://github.com/OutSystems/Cordova-sqlite-storage/pull/9
Additional Debug Information:
03-19 12:44:53.121 E/SQLitePlugin(16860): unexpected error, stopping db thread
03-19 12:44:53.121 E/SQLitePlugin(16860): java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String io.liteglue.SQLDatabaseHandle.getLastErrorMessage()' on a null object reference
03-19 12:44:53.121 E/SQLitePlugin(16860): at io.liteglue.SQLiteGlueConnection.<init>(SQLiteGlueConnection.java:12)
03-19 12:44:53.121 E/SQLitePlugin(16860): at io.liteglue.SQLiteConnector.newSQLiteConnection(SQLiteConnector.java:20)
03-19 12:44:53.121 E/SQLitePlugin(16860): at io.sqlc.SQLiteConnectorDatabase.open(SQLiteConnectorDatabase.java:55)
03-19 12:44:53.121 E/SQLitePlugin(16860): at io.sqlc.SQLitePlugin.openDatabase(SQLitePlugin.java:213)
03-19 12:44:53.121 E/SQLitePlugin(16860): at io.sqlc.SQLitePlugin.access$000(SQLitePlugin.java:28)
03-19 12:44:53.121 E/SQLitePlugin(16860): at io.sqlc.SQLitePlugin$DBRunner.run(SQLitePlugin.java:328)
03-19 12:44:53.121 E/SQLitePlugin(16860): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
03-19 12:44:53.121 E/SQLitePlugin(16860): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
03-19 12:44:53.121 E/SQLitePlugin(16860): at java.lang.Thread.run(Thread.java:923)
@magynhard you should see that I have already merged your PR on the test app. I did reach out to browserstack.com for the open source testing and hope to end up with some positive results.
It looks to me like OutSystems solved it by using a complex type in the NDK library, and I am thinking about incorporating their updates if I can get some confirmation from others that it will actually solve this problem. The one thing is that they have dropped Android 5.1 support, which I am not yet ready to do on this plugin.
Another quick update: Browser Stack has approved me for the open source testing for 1 year. Thanks to @magynhard for the suggestion!
I will start using Browser Stack to test on multiple Android 11 devices. I will try both the existing plugin and a version with the fixes from OutSystems#9. I may need a few days to have some meaningful results worth posting.
Any input from the user community would be much appreciated on this issue.
Hello guys,
I can confirm you that https://github.com/OutSystems/Cordova-sqlite-storage/pull/9 fixed the issue with Android 11 devices.
Thanks!
I have tested on Pixel 5 with help from Browser Stack, reproduced the issue, and it seems to be solved by the OutSystems fork.
I would like to do some more testing before updating this plugin.
P.S. I tested the OutSystems fork from here: https://github.com/brodybits/cordova-sqlite-test-app/tree/android-sdk-30-outsystems-fork-test
P.P.S. The actual solution is in the following PRs:
The details are in the commit message of this commit: https://github.com/OutSystems/Android-sqlite-native-driver/commit/6a19159e9fd8bfd0b995b61511444b4a71e9f3bb
P.S. 3: Adding reference to a corresponding discussion on cordova-android: https://github.com/apache/cordova-android/issues/1006
Planning to bump the default Android SDK Target to 30, but not until cordova-android 10.0.0.
I have just published version 6.0.0 with the enhancements to the Android JAR libraries from OutSystems. This issue should be resolved now.
@brodybits thank you very much for your fast reaction.
I will check it and give some feedback.
Where can i find the button to donate a coffe to you?
@magynhard please keep me posted. I may be a little slow for the next 1-2 weeks but would definitely love to know the result.
Your suggestion to use Browser Stack was already good payment for this update, and I have already suggested to Apache Cordova to start using it as well. I think many others will benefit from this update over time. But here is my PayPal address if you insist: [email protected]
Thanks for the tip, time for a good coffee!
@brodybits after updating the plugin dependency to 6.0.0 everything is working fine with android 11 ๐๐ป
... and Android SDK Target 30 ... right?
Yeah ๐ ๐
๐ธ Of course SDK target 30! ๐
Otherwise i would not have been able to release any new version with your active plugin at android 11 on the play store ๐ฑ
You saved my release deadline next week โ
Thanks for the fix, @brodybits .
Hat tip should go to @luissilvaos. You are welcome!
Hey!
I'm hoping I can chip in with some useful info but take this with a pinch of salt as I've not sanity checked this.
When setting the targetSDK to 30 as the author mentions it would fail to open the database on Android 11. It wouldn't happen on all devices though. We saw it on the latest generation of Pixels most notably so the 4A, 4A (5G) and 5.
We tried the Pixel 4 & 3A and they worked fine. All devices tested were on A11.
Sorry I know that's probably not much use but hopefully helps a little ๐
I am finding the same thing: works fine on Pixel 2, and Samsung S20, but fails on Pixel 4a and Pixel 5
The most recent version of cordova-sqlite-storage should now be working on Pixel 4a and 5. If not, please raise a new issue with a minimal reproduction. Thanks.
Most helpful comment
I have just published version 6.0.0 with the enhancements to the Android JAR libraries from OutSystems. This issue should be resolved now.