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

BUG : Fatal Exception: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (Sqlite code 14): Could not open database, (OS error - 2:No such file or directory) #479

Closed
jiebo opened this issue Sep 8, 2024 · 8 comments · Fixed by #480
Assignees
Labels
bug Something isn't working

Comments

@jiebo
Copy link

jiebo commented Sep 8, 2024

Describe the bug
From our Firebase Crashlytics, we are seeing an issue that seems to be caused by DefaultPersistence.getWritableDatabase. Please check the stack trace below.

Stack Trace

Fatal Exception: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (Sqlite code 14): Could not open database, (OS error - 2:No such file or directory)
       at android.database.sqlite.SQLiteConnection.nativeOpen(SQLiteConnection.java)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:223)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:207)
       at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:511)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:194)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:183)
       at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:880)
       at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:864)
       at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:767)
       at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:739)
       at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:289)
       at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:235)
       at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:175)
       at com.rudderstack.android.sdk.core.persistence.DefaultPersistence.getWritableDatabase(DefaultPersistence.java:54)
       at com.rudderstack.android.sdk.core.persistence.DefaultPersistence.isAccessible(DefaultPersistence.java:261)
       at com.rudderstack.android.sdk.core.DBPersistentManager.checkIfColumnExists(DBPersistentManager.java:487)
       at com.rudderstack.android.sdk.core.DBPersistentManager.lambda$checkForMigrations$2(DBPersistentManager.java:519)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
       at java.lang.Thread.run(Thread.java:776)

Over the past 7 days, we've recorded 43k crashes for 447 users. Here are the device details

  • Android Version: 75% Android 9, 16% Android 7
  • Devices: 93% Amazon
  • 99% of events occurred while app is in the background

Version of the Android SDK
We're using 1.22.0 of the Rudderstack Android SDK.

Mobile device mode integration

rudderstack-android-sdk-core = { module = "com.rudderstack.android.sdk:core", version.ref = "rudderstack" }

SDK initialisation snippet

    fun build(): RudderClient {
        return RudderClient.getInstance(
            context,
            key,
            RudderConfig.Builder()
                .withDataPlaneUrl(domain)
                .withRecordScreenViews(false)
                .withLogLevel(RudderLogLevel.NONE)
                .build()
        )
    }

Check for Correct Usage of writeKey and dataPlaneUrl
Events are flowing as expected

@jiebo jiebo added the bug Something isn't working label Sep 8, 2024
@1abhishekpandey 1abhishekpandey self-assigned this Sep 9, 2024
@1abhishekpandey
Copy link
Contributor

Hey @jiebo,

Thanks for raising this issue.

I investigated this issue, and it appears to be caused by the storage permission not being granted. The problem occurs right when the Rudder Android SDK initialization starts.

For now, could you please try the following steps:

  1. Ensure the following permission is added to your app (if it’s not already included). You can refer to the thread here: https://stackoverflow.com/a/19783139.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  1. Update the Rudder Android SDK to the latest version v1.25.0.

Additionally, I would like to clarify a few points:

  1. Do you have the logic to initialise the SDK in the background?
  2. Have you been able to track any events using the Amazon device?
  3. What type of Amazon device is experiencing this issue?
  4. Have you noticed this error on other Android devices as well?
  5. Since we do not have an Amazon device to reproduce the issue, could you suggest if there is any simulator we could use for testing? Any steps or suggestions regarding that would be appreciated.
  6. Have you been able to reproduce this issue on your end?

@1abhishekpandey
Copy link
Contributor

Hey @jiebo,

Could you please provide the information requested above?

@jiebo
Copy link
Author

jiebo commented Sep 24, 2024

Hi @1abhishekpandey, sorry for the delayed response. We updated the Adapty SDK version to 1.25.0 but the issue is still persisting. Also, we already have the WRITE_EXTERNAL_STORAGE permission added.

For the next few points you requested:

  1. Nope, we don't initialise the SDK in the background, only on app start
  2. We're unable to verify this because we don't collect the user's device manufacturer
  3. 46% - Fire TV Stick 4K Max - 1st Gen (2021), 14% - Fire TV Stick - 3rd Gen (2020), 11% - Nebula Soundbar - Fire TV Edition (2019)
  4. Yes, a variety of TV devices, e.g., Xiaomi
  5. I'm not aware of any
  6. Unfortunately, we have not been able to reproduce this issue as well

For what it's worth, since the call site is within Rudderstack's code, is it possible to simply try-catch the exception?

@1abhishekpandey
Copy link
Contributor

Hey @jiebo,

We were also considering catching this exception, as you mentioned, since we haven't been able to reproduce the crash on any simulator devices. We will plan to work on this fix soon.

Meanwhile can you please help us with one more info:

  1. How many total % of your events are getting affected by this crash?

@jiebo
Copy link
Author

jiebo commented Sep 24, 2024

Hello, I don't think it's possible to know the percentage of events affected by this crash since we don't know how many events we will get actually get without the crash. That being said, I don't suppose it to be a huge number.
However, because it occurs in the background and silently, this particular crash accounts for more than half of all our recorded crashes.

@1abhishekpandey 1abhishekpandey linked a pull request Oct 14, 2024 that will close this issue
10 tasks
@1abhishekpandey
Copy link
Contributor

Hey @jiebo,

We have released a fix in v1.25.1. Please try it and let us know if it successfully resolves your issue.

@1abhishekpandey
Copy link
Contributor

Hey @jiebo,
Have you had a chance to try the fix? If so, could you please let us know the results?

@jiebo
Copy link
Author

jiebo commented Oct 24, 2024

Hi @1abhishekpandey, sorry for the late response. Yes, we've updated to the new version and we can confirm that the issue is resolved, please close this issue as needed. Thanks for the quick turnaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants