Can’t create directory and application crashes

Hi,
In ODK collect on Samsung device when I try to open ODK collect app it Crashes.
While debugging it in Log the error message is
can’t create directory: /storage/emulated/sdcard0Android/data/org.odk.collect.android/files/projects/DEMO/forms
kindly let us know what might be the issue here.

Hi @Naveen_Harnehiya
Welcome to the ODK forum. We're glad you're here. When you get a chance, please introduce yourself on this forum thread.

Could you tell us more about your device (model, android version)?
Then what ODK Collect version are you using?
Did that happen immediately after installing the app or maybe you were able to use it and then something happened?

Hi @Grzesiek2010
Again encountered same issue, now i have details that error is in
Android OS: 11 and 12
ODK Collect version: ODK Collect v2021.2.0
I uninstalled app first and then installed, it crashed immediately not able to open app.

How did you install the app? From the Play Store or maybe you built it on your own?
Have you experienced problems like that with other apps?

This is an exact copy from the log, right? There's a / missing between sdcard0 and Android which would certainly explain a hard crash like one you've described.

In addition to the questions @Grzesiek2010 asked above, it would be helpful to know whether you have an external sdcard in the device(s) you've had this problem with.

Thanks for reply.
I build it in android studio using code from git repo. this Issue is in android 11 and 12 on 5G samsung Galaxy A53 device .
I can easily reproduce it by installing older version like v1.30.1 or v2021.2.0 then uninstall it and now install latest odk version, it will crash on opening the app.

In my current device there is no sd card
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{org.odk.collect.android.activities.SplashScreenActivity}: java.lang.RuntimeException: Cannot create directory: /storage/emulated/0/Android/data/org.odk.collect.android/files/projects/DEMO/forms

Are you saying this ONLY happens if you install a prior version from the Play Store and then install your build? I believe that's expected. The directory is created by the Play Store build which is signed with the ODK key. If you then build the same app but with a different signing key you should not be able to take over the original directory.

If there are features not available in the Play Store build that you need, consider writing up a description of what you need in the Features category. If you must do a custom build, change the applicationId.

I am getting this crash by following steps:
Device is Samsung Galaxy A53 (5G phone)
Step1. installed ODK app version v1.30.1 by compiling source code from Git, using Android Studio.
Step2. Uninstalled the app from device (Ideally All app related folders should be deleted from memory).
Step3. Installed latest version of ODK by compiling source code from Git, using Android Studio.
Step4. Launch ODK app (App crashed on opening).

Thanks for reproduction steps. I've just tried but to no avail... maybe it's something device specific.
@kkrawczyk123 @Szymon_Rujner please check it on your devices when you are free.

1 Like

Hi,
Thanks, ODK team, for checking this issue on priority, we tried to narrow down this issue and found that it is reproducible on some of SAMSUNG 5g devices, can you please check with any Samsung 5G device?

Hi,
@Grzesiek2010 I tried to reproduce the issue in different ways on Android 10: Xiaomi Redmi 9T and Android 11: Pixel 3a and I was not able to do this on both devices

1 Like

@ShubhamArora are you with the same project as @Naveen_Harnehiya or are you getting the same issue with the Play Store download?

What happens if you reboot the device before reinstalling?

We don't have access to any of those. Device-specific issues typically need to be handled either with a firmware update or an update to Android. They would be outside of what we can help troubleshoot.

Hi,
Yes, I am working with Naveen, I am getting the same issue with the play store download,
I tried to reboot the device, but it also not worked.

Hi!
I was able to reproduce that issue on my Android 5.1 device. I have already sent logs to @Grzesiek2010 and I can also share that device with him if he will need it.

1 Like

Cool! The logs I got from @kkrawczyk123 look like those we see on firebase so it's the same reason. I will take that device and try to play with it.
Meanwhile @Naveen_Harnehiya and @ShubhamArora could you try to pull the latest changes from our repository and reproduce the crash again? We have added some more info to our logs so you also should see more details. Please share them so that we can compare to see if it's the same reason.

1 Like

Thanks, ODK team
I will test with the latest source code as well and will share our findings with you.

I Just tested,
Latest ODK app is crashing

Yeah i know what i meant was that we added more logs so if you use Android Studio you should be able to see them. Could you share it here?

2022-05-19 14:36:15.046 13281-13425/? E/SQLiteDatabase: Failed to open database '/storage/emulated/0/Android/data/org.odk.collect.android/files/projects/DEMO/metadata/instances.db'.
android.database.sqlite.SQLiteCantOpenDatabaseException: Cannot open database '/storage/emulated/0/Android/data/org.odk.collect.android/files/projects/DEMO/metadata/instances.db': Directory /storage/emulated/0/Android/data/org.odk.collect.android/files/projects/DEMO/metadata doesn't exist
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:371)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:226)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:736)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:284)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:251)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:1415)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:1356)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:997)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:470)
at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:437)
at org.odk.collect.android.database.DatabaseConnection.getReadableDatabase(DatabaseConnection.kt:28)
at org.odk.collect.android.database.instances.DatabaseInstancesRepository.query(DatabaseInstancesRepository.java:217)
at org.odk.collect.android.database.instances.DatabaseInstancesRepository.getCursorForAllByStatus(DatabaseInstancesRepository.java:213)
at org.odk.collect.android.database.instances.DatabaseInstancesRepository.getCountByStatus(DatabaseInstancesRepository.java:108)
at org.odk.collect.android.formmanagement.InstancesAppState.update(InstancesAppState.kt:36)
at org.odk.collect.android.activities.viewmodels.MainMenuViewModel.lambda$refreshInstances$0(MainMenuViewModel.java:121)
at org.odk.collect.android.activities.viewmodels.MainMenuViewModel.$r8$lambda$YcoOrSsMfVfE3us74hHtJ7C_gUA(Unknown Source:0)
at org.odk.collect.android.activities.viewmodels.MainMenuViewModel$$ExternalSyntheticLambda1.get(Unknown Source:2)
at org.odk.collect.async.CoroutineScheduler$immediate$1$result$1.invokeSuspend(CoroutineScheduler.kt:16)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:39)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 2318 SQLITE_CANTOPEN_EACCES[2318]): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:341)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:226)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:736)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:284)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:251)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:1415)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:1356)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:997)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:470)
at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:437)
at org.odk.collect.android.database.DatabaseConnection.getReadableDatabase(DatabaseConnection.kt:28)
at org.odk.collect.android.database.instances.DatabaseInstancesRepository.query(DatabaseInstancesRepository.java:217)
at org.odk.collect.android.database.instances.DatabaseInstancesRepository.getCursorForAllByStatus(DatabaseInstancesRepository.java:213)
at org.odk.collect.android.database.instances.DatabaseInstancesRepository.getCountByStatus(DatabaseInstancesRepository.java:108)
at org.odk.collect.android.formmanagement.InstancesAppState.update(InstancesAppState.kt:36)
at org.odk.collect.android.activities.viewmodels.MainMenuViewModel.lambda$refreshInstances$0(MainMenuViewModel.java:121)
at org.odk.collect.android.activities.viewmodels.MainMenuViewModel.$r8$lambda$YcoOrSsMfVfE3us74hHtJ7C_gUA(Unknown Source:0)
at org.odk.collect.android.activities.viewmodels.MainMenuViewModel$$ExternalSyntheticLambda1.get(Unknown Source:2)
at org.odk.collect.async.CoroutineScheduler$immediate$1$result$1.invokeSuspend(CoroutineScheduler.kt:16)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:39)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
2022-05-19 14:36:15.046 13281-13425/? E/SQLiteOpenHelper: Couldn't open instances.db for writing (will try read-only):
android.database.sqlite.SQLiteCantOpenDatabaseException: Cannot open database '/storage/emulated/0/Android/data/org.odk.collect.android/files/projects/DEMO/metadata/instances.db': Directory /storage/emulated/0/Android/data/org.odk.collect.android/files/projects/DEMO/metadata doesn't exist
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:371)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:226)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:736)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:284)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:251)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:1415)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:1356)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:997)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:470)
at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:437)
at org.odk.collect.android.database.DatabaseConnection.getReadableDatabase(DatabaseConnection.kt:28)
at org.odk.collect.android.database.instances.DatabaseInstancesRepository.query(DatabaseInstancesRepository.java:217)
at org.odk.collect.android.database.instances.DatabaseInstancesRepository.getCursorForAllByStatus(DatabaseInstancesRepository.java:213)
at org.odk.collect.android.database.instances.DatabaseInstancesRepository.getCountByStatus(DatabaseInstancesRepository.java:108)
at org.odk.collect.android.formmanagement.InstancesAppState.update(InstancesAppState.kt:36)
at org.odk.collect.android.activities.viewmodels.MainMenuViewModel.lambda$refreshInstances$0(MainMenuViewModel.java:121)
at org.odk.collect.android.activities.viewmodels.MainMenuViewModel.$r8$lambda$YcoOrSsMfVfE3us74hHtJ7C_gUA(Unknown Source:0)
at org.odk.collect.android.activities.viewmodels.MainMenuViewModel$$ExternalSyntheticLambda1.get(Unknown Source:2)
at org.odk.collect.async.CoroutineScheduler$immediate$1$result$1.invokeSuspend(CoroutineScheduler.kt:16)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:39)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 2318 SQLITE_CANTOPEN_EACCES[2318]): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:341)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:226)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:736)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:284)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:251)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:1415)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:1356)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:997)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:470)
at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:437)
at org.odk.collect.android.database.DatabaseConnection.getReadableDatabase(DatabaseConnection.kt:28)
at org.odk.collect.android.database.instances.DatabaseInstancesRepository.query(DatabaseInstancesRepository.java:217)
at org.odk.collect.android.database.instances.DatabaseInstancesRepository.getCursorForAllByStatus(DatabaseInstancesRepository.java:213)
at org.odk.collect.android.database.instances.DatabaseInstancesRepository.getCountByStatus(DatabaseInstancesRepository.java:108)
at org.odk.collect.android.formmanagement.InstancesAppState.update(InstancesAppState.kt:36)
at org.odk.collect.android.activities.viewmodels.MainMenuViewModel.lambda$refreshInstances$0(MainMenuViewModel.java:121)
at org.odk.collect.android.activities.viewmodels.MainMenuViewModel.$r8$lambda$YcoOrSsMfVfE3us74hHtJ7C_gUA(Unknown Source:0)
at org.odk.collect.android.activities.viewmodels.MainMenuViewModel$$ExternalSyntheticLambda1.get(Unknown Source:2)
at org.odk.collect.async.CoroutineScheduler$immediate$1$result$1.invokeSuspend(CoroutineScheduler.kt:16)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:39)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
2022-05-19 14:36:15.046 13281-13425/? E/SQLiteLog: (14) cannot open file at line 41187 of [bcd014c473]
2022-05-19 14:36:15.046 13281-13425/? E/SQLiteLog: (14) os_unix.c:41187: (13) lstat(/storage/emulated/0/Android/data/org.odk.collect.android/files/projects/DEMO/metadata/instances.db) -
2022-05-19 14:36:15.046 13281-13425/? E/SQLiteLog: (1) Process collect.android : Pid (13281) Uid (10422) Euid (10422) Gid (10422) Egid (10422)
2022-05-19 14:36:15.046 13281-13425/? E/SQLiteLog: (1) osStat failed "/storage/emulated/0/Android/data/org.odk.collect.android/files/projects/DEMO/metadata/instances.db" due to error (13)
2022-05-19 14:36:15.046 13281-13425/? E/SQLiteLog: (1) osStat failed "/storage/emulated/0/Android/data/org.odk.collect.android/files/projects/DEMO/metadata" due to error (13)
2022-05-19 14:36:15.046 13281-13425/? E/SQLiteLog: (1) osStat failed "/storage/emulated/0/Android/data/org.odk.collect.android/files/projects/DEMO" due to error (13)
2022-05-19 14:36:15.046 13281-13425/? E/SQLiteLog: (1) Stat of /storage/emulated/0/Android/data/org.odk.collect.android/files/projects : st_mode(42770) st_uid(10395) st_gid(1078) st_ino(27152)
2022-05-19 14:36:15.046 13281-13425/? E/SQLiteLog: (1) Stat of /storage/emulated/0/Android/data/org.odk.collect.android/files : st_mode(42770) st_uid(10422) st_gid(1078) st_ino(83634)
2022-05-19 14:36:15.046 13281-13425/? E/SQLiteLog: (1) Stat of /storage/emulated/0/Android/data/org.odk.collect.android : st_mode(42770) st_uid(10422) st_gid(1078) st_ino(114325)
2022-05-19 14:36:15.046 13281-13425/? E/SQLiteLog: (1) Stat of /storage/emulated/0/Android/data : st_mode(42771) st_uid(1023) st_gid(1078) st_ino(6024)
2022-05-19 14:36:15.046 13281-13425/? E/SQLiteLog: (1) Stat of /storage/emulated/0/Android : st_mode(42771) st_uid(1023) st_gid(1023) st_ino(6027)
2022-05-19 14:36:15.046 13281-13425/? E/SQLiteLog: (1) Stat of /storage/emulated/0 : st_mode(42770) st_uid(1023) st_gid(1023) st_ino(6306)
2022-05-19 14:36:15.046 13281-13425/? E/SQLiteLog: (1) Stat of /storage/emulated : st_mode(40770) st_uid(1023) st_gid(1023) st_ino(652)
2022-05-19 14:36:15.046 13281-13425/? E/SQLiteLog: (1) Stat of /storage : st_mode(40711) st_uid(2000) st_gid(9997) st_ino(16)
2022-05-19 14:36:15.047 13281-13425/? E/SQLiteDatabase: Failed to open database '/storage/emulated/0/Android/data/org.odk.collect.android/files/projects/DEMO/metadata/instances.db'.
android.database.sqlite.SQLiteCantOpenDatabaseException: Cannot open database '/storage/emulated/0/Android/data/org.odk.collect.android/files/projects/DEMO/metadata/instances.db': Directory /storage/emulated/0/Android/data/org.odk.collect.android/files/projects/DEMO/metadata doesn't exist
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:371)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:226)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:736)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:284)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:251)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:1415)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:1356)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:997)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:480)
at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:437)
at org.odk.collect.android.database.DatabaseConnection.getReadableDatabase(DatabaseConnection.kt:28)
at org.odk.collect.android.database.instances.DatabaseInstancesRepository.query(DatabaseInstancesRepository.java:217)
at org.odk.collect.android.database.instances.DatabaseInstancesRepository.getCursorForAllByStatus(DatabaseInstancesRepository.java:213)
at org.odk.collect.android.database.instances.DatabaseInstancesRepository.getCountByStatus(DatabaseInstancesRepository.java:108)
at org.odk.collect.android.formmanagement.InstancesAppState.update(InstancesAppState.kt:36)
at org.odk.collect.android.activities.viewmodels.MainMenuViewModel.lambda$refreshInstances$0(MainMenuViewModel.java:121)
at org.odk.collect.android.activities.viewmodels.MainMenuViewModel.$r8$lambda$YcoOrSsMfVfE3us74hHtJ7C_gUA(Unknown Source:0)
at org.odk.collect.android.activities.viewmodels.MainMenuViewModel$$ExternalSyntheticLambda1.get(Unknown Source:2)
at org.odk.collect.async.CoroutineScheduler$immediate$1$result$1.invokeSuspend(CoroutineScheduler.kt:16)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:39)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 2318 SQLITE_CANTOPEN_EACCES[2318]): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)