You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Android 11 Open database failed. Could not open database on some Android devices #462
Some of our users have reported an issue related to the SQLite lib. After updating their phone's OS( Color OS) to 11(Android 11), SQLite operation is broken. In debug mode I see below error:
OPEN database: StorageExtension.db failed, aborting any pending transactions
and following if trying to call any transaction:
error: openDatabase {"dblocation": "nosync", "location": "default", "name": "StorageExtension.db"} [[Error: Could not open database]]
I have verified the app and plugin work fine on Color OS 7 and 10, but broken on 11.
after looking into the Android code of the plugin, i found that the operation failed at long var1 = SQLiteNative.sqlc_db_open(this.dbfilename, this.openflags); which returns negative value on Android 11 while returning 0 on lower versions. Possible related reports in other sqlite implementation: brody2consult/cordova-sqlite-storage#954 (comment)
I'm experiencing similar issues. batch execution error: database not open after opening the database and receiving confirmation it's open
and database already open: <databasename>
These are only appearing in Android 11, Android 10 is fine.
@LeeKyungJoon , this is not a pre-populated database. This issue happens on specific OS/Devices only. What device/OS did you use? My testing on huawei and Samsung were all fine, but Oppo/ColorOS fails.
If your target SDK is 29, it runs fine on Android 11, but since Google forces all app updates to target 30 or above, this is no longer an option. We have 4 month left to do the update.
Reacted by AmolFC, Himanshu Ahuja, Fateme Mirzaei, Riski Arifani, briancalma and Yousha Arshad
Hi, Did you find a solution for this? I know public external storage changed from Android 11. But I am not sure where to put my sqlite database and how to access this. Db must not be deleted if app is uninstalled. Other apps must also be able access this sqlite db.
Facing the Similar issue. It is showing the following error on my Samsung Galaxy M51 device.
Android Version: 11
OneUI Version: 3.1
LOG new transaction is waiting for open operation
LOG OPEN database: master.db failed, aborting any pending transactions
LOG error: openDatabase {"dblocation": "nosync", "name": "master.db"} [[Error: Could not open database]]
P.S. This is only happening when i make the targetSDKVersion 30. It is working fine on targetSDKVersion 29.
Seeing this issue as well now, once I started targeting SDK Version 30 (RN65+).
I am not an Android expert, but I believe it is something related to this article (https://developer.android.com/about/versions/11/privacy/storage#permissions-target-11), which details that once you target SDK 30, you now must use the modern permissions system for accessing disks (on all versions). I was using the android-native version, which might be part of the problem here.
Facing a similar issue as well.
Tested on Android 9.0 API 28, Android 10.0 API 29 and Android 11 API 30.
My use case is as follows:
Download a zipped db file from remote server into a cache directory, unzip it and place it into a Documents folder.
This workflow works well with "expo-sqlite" library, I can sucessfully download, unzip and load the db.
While trying to reproduce it with the "react-native-sqlite-storage" I'm getting the "Error: Could not open database" issue.
I'm using the following command for opening the database:
Also, I've confirmed that the "mydatabase.sqlite" file does indeed exist on the "/data/user/0/com.myapp/files/SQLite/" folder.
However, if I manually place the "mydatabase.sqlite" file directly into my project android asset's folder ("android/app/src/main/assets") and change the opening command attribute "createFromLocation" to "~mydatabase.sqlite", the database loads!
I've noticed that I'm using an absolute path for the first example, while on the second I'm using a relative path... Could it be a reason for the issue I'm seeing?
If someone could shed some light on this, I would be very gratefull...
Related to this and PR #492 .... curiously enough ... I removed the custom SQLite build and used the device's SQLite and I got it to work with my existing code.
i.e. I removed this from the react-native.config.js and it worked.
Reacted by Himanshu Ahuja, Andrew M., Andrea Cassani, Amir Khan, Andres D. Paladines, Krishna Vishwakarma , Arjun Ghimire, Libardo Vega, kim, Sangja and 8 more
Reacted by Ehsan Hejazi, Muhammad Olacoded and Christian glacet
Reacted by Andres D. Paladines, Krishna Vishwakarma , Arjun Ghimire, Christiaan Färber and Andy Ngo
Reacted by Andres D. Paladines, Krishna Vishwakarma , Arjun Ghimire, kim, Christiaan Färber and Andy Ngo
Reacted by Andres D. Paladines, Krishna Vishwakarma , Arjun Ghimire, kim and Andy Ngo
Can you tell us what are the changes you have done here so we can have an idea? thanks in advance
I have added new android native libraries patches which is under /platforms/android-native/libs other parts are remained the same,
so now you can switch your android target API to 30 and there will be no bugs and errors
The app is crashing on apk release
Please create an issue with more details under the package github so we can track it
Can you tell us what are the changes you have done here so we can have an idea? thanks in advance
I have added new android native libraries patches which is under /platforms/android-native/libs other parts are remained the same,
so now you can switch your android target API to 30 and there will be no bugs and errors
The app is crashing on apk release
Please create an issue with more details under the package github so we can track it
Related to this and PR #492 .... curiously enough ... I removed the custom SQLite build and used the device's SQLite and I got it to work with my existing code.
i.e. I removed this from the react-native.config.js and it worked.
Removing it solves for Android 11 however android 10 will not work.
Device I am testing are Motorola One 5G Ace - Android 11 and Galaxy S9+ Android 10 (also another motorola One using Android 10 )
Related to this and PR #492 .... curiously enough ... I removed the custom SQLite build and used the device's SQLite and I got it to work with my existing code.
i.e. I removed this from the react-native.config.js and it worked.
Due to maintainer inactivity to accept PRs I've created another package based on this package with new android native libraries for API 30 available to use:
Activity
TheGameNewWorldOrder commentedon Jan 13, 2021
after looking into the Android code of the plugin, i found that the operation failed at
long var1 = SQLiteNative.sqlc_db_open(this.dbfilename, this.openflags);which returns negative value on Android 11 while returning 0 on lower versions. Possible related reports in other sqlite implementation: brody2consult/cordova-sqlite-storage#954 (comment)kinor commentedon Jan 25, 2021
Hi. Has there been any movement in resolving this problem?
Thanks
andpor commentedon Jan 25, 2021
@kinor not able to allocate time to this but all PR (backward compatible and also covering Android native) are welcome.
bekkii77 commentedon Jan 27, 2021
I'm experiencing similar issues.
batch execution error: database not openafter opening the database and receiving confirmation it's openand
database already open: <databasename>These are only appearing in Android 11, Android 10 is fine.
LeeKyungJoon commentedon Mar 19, 2021
I run well on Android 11.
Looking at the uploaded code, createFromLocation is missing.
I think it should be necessary. Add it and try it out.
TheGameNewWorldOrder commentedon Jun 9, 2021
@LeeKyungJoon , this is not a pre-populated database. This issue happens on specific OS/Devices only. What device/OS did you use? My testing on huawei and Samsung were all fine, but Oppo/ColorOS fails.
TheGameNewWorldOrder commentedon Jun 9, 2021
If your target SDK is 29, it runs fine on Android 11, but since Google forces all app updates to target 30 or above, this is no longer an option. We have 4 month left to do the update.
KarenMuller commentedon Jul 13, 2021
Hi, Did you find a solution for this? I know public external storage changed from Android 11. But I am not sure where to put my sqlite database and how to access this. Db must not be deleted if app is uninstalled. Other apps must also be able access this sqlite db.
AmolFC commentedon Aug 30, 2021
Any update on this? App is not working on many devices with Android 11 now.
himu243 commentedon Sep 2, 2021
Facing the Similar issue. It is showing the following error on my Samsung Galaxy M51 device.
Android Version: 11
OneUI Version: 3.1
LOG new transaction is waiting for open operation
LOG OPEN database: master.db failed, aborting any pending transactions
LOG error: openDatabase {"dblocation": "nosync", "name": "master.db"} [[Error: Could not open database]]
P.S. This is only happening when i make the targetSDKVersion 30. It is working fine on targetSDKVersion 29.
Can someone please help on this one?
Thanks in Advance
zzorba commentedon Oct 8, 2021
Seeing this issue as well now, once I started targeting SDK Version 30 (RN65+).
I am not an Android expert, but I believe it is something related to this article (https://developer.android.com/about/versions/11/privacy/storage#permissions-target-11), which details that once you target SDK 30, you now must use the modern permissions system for accessing disks (on all versions). I was using the
android-nativeversion, which might be part of the problem here.intentzero commentedon Oct 8, 2021
Facing a similar issue as well.
Tested on Android 9.0 API 28, Android 10.0 API 29 and Android 11 API 30.
My use case is as follows:
Download a zipped db file from remote server into a cache directory, unzip it and place it into a Documents folder.
This workflow works well with "expo-sqlite" library, I can sucessfully download, unzip and load the db.
While trying to reproduce it with the "react-native-sqlite-storage" I'm getting the "Error: Could not open database" issue.
I'm using the following command for opening the database:
Also, I've confirmed that the "mydatabase.sqlite" file does indeed exist on the "/data/user/0/com.myapp/files/SQLite/" folder.
However, if I manually place the "mydatabase.sqlite" file directly into my project android asset's folder ("android/app/src/main/assets") and change the opening command attribute "createFromLocation" to "~mydatabase.sqlite", the database loads!
I've noticed that I'm using an absolute path for the first example, while on the second I'm using a relative path... Could it be a reason for the issue I'm seeing?
If someone could shed some light on this, I would be very gratefull...
Many thanks in advance!
rblalock commentedon Oct 12, 2021
I am running into an identical problem.
Related to this and PR #492 .... curiously enough ... I removed the custom SQLite build and used the device's SQLite and I got it to work with my existing code.
i.e. I removed this from the react-native.config.js and it worked.
himu243 commentedon Oct 20, 2021
@rblalock It worked for me as well but not sure how is it working. Can you please explain that as well?
rblalock commentedon Oct 20, 2021
I assume it has to do with the drivers for SQLite but I'm not 100% sure
32 remaining items
castalonirenz commentedon Apr 30, 2022
The app is crashing on apk release
Ehsan0Hejazi commentedon Apr 30, 2022
Please create an issue with more details under the package github so we can track it
castalonirenz commentedon Apr 30, 2022
thanks
castalonirenz commentedon Apr 30, 2022
Here is the logcat from apk release build
Ehsan0Hejazi commentedon Apr 30, 2022
ok I think I found the problem
just follow this
in react-native.config.js
your dependencies should be as follows
you are exporting "react-native-sqlite-storage" while you need to export "react-native-sqlite-storage-api30"
let me know if your problem is solved
amirkhanzada51 commentedon May 3, 2022
Hey, you save my soul. after 2 days of headache finally, solve the problem.
Raj797979 commentedon Oct 10, 2022
can you guide me cause i'm getting same issue with android version 11 and above
usmanmalik333 commentedon Jan 30, 2023
still not working on android 11 any solution ? if we removed the dependencies then it not working on other android version
amf-paulinho commentedon Feb 6, 2023
I am having same problem. Is this still open?
if I want to use SQLite that comes with the library Android 11 cant open the database, If I use the Device SQLite lots of Android 10 will crash.
this is my config file:
Removing it solves for Android 11 however android 10 will not work.
Device I am testing are Motorola One 5G Ace - Android 11 and Galaxy S9+ Android 10 (also another motorola One using Android 10 )
There is no solution still ?
shiroze commentedon Mar 1, 2023
Not working on Android 11+ on Device Redmi Note 9 Pro
LaGregance commentedon Jun 26, 2023
Thanks a lot, it's work for me, just note in order to not break others package that are based on it, you can install the package like that:
So you can refer to it using standard
import XXX from 'react-native-sqlite-storage'hengkx commentedon Aug 21, 2023
Do you have any solutions?
Mohammed-Aljasem commentedon May 13, 2024
any updates ?
LaGregance commentedon Jun 21, 2024
Hi,
I've created a fork of this repository that bring multiple things:
The fork is a drop in remplacement of this repository.
To see it, click here: https://www.npmjs.com/package/@boltcode/react-native-sqlite-storage
If you want to understand what I've done in this fork, there is a documentation about it.
Have a good day.
antoinerousseau commentedon Dec 23, 2024
Still having the issue on Android 14/15
boltcode-js/react-native-sqlite-storage#3