Closed dave7895 closed 6 months ago
I think I may have found the source of the crash at least.
I have already installed lespas on my smartphone, where I do have an sd card and also set lespas to store the images there. So lespas probably reads the config that it downloads from the nextcloud server, sets the KEY_STORAGE_LOCATION
to true but this errors on my tablet. I realized this because when setting a breakpoint and setting the KSL to false it opened and had all my preferences already put in.
I guess this could be circumvented by having the on server preferences file have a name dependent on the device name or by checking if an SD card is available when restoring preferences from server.
Code checking SD card availability at app startup is located in MainActivity
's onCreate
, sadly in the current implementation, it's not executed during the very first app startup which is the situation you are encountering. This is a bug. I will see what I can do. Thanks for reporting.
Describe the bug Lespas crashes or never finishes loading when opening it.
To Reproduce Steps to reproduce the behavior: To just stall
Expected behavior open the folder overview
Screenshots If applicable, add screenshots to help explain your problem.
Tablet
Additional context have built it locally, will add logcat below, and tried the version from google play, crashed as well
logcat entry
``` FATAL EXCEPTION: main Process: site.leos.apps.lespas, PID: 19969 java.lang.RuntimeException: Unable to start activity ComponentInfo{site.leos.apps.lespas/site.leos.apps.lespas.MainActivity}: java.lang.RuntimeException: Cannot create an instance of class site.leos.apps.lespas.sync.ActionViewModel at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4184) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4340) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2584) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8810) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) Caused by: java.lang.RuntimeException: Cannot create an instance of class site.leos.apps.lespas.sync.ActionViewModel at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.kt:318) at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.kt:302) at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.kt:276) at androidx.lifecycle.SavedStateViewModelFactory.create(SavedStateViewModelFactory.kt:128) at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.kt:184) at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.kt:150) at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:53) at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:35) at site.leos.apps.lespas.MainActivity.getActionsPendingModel(MainActivity.kt:69) at site.leos.apps.lespas.MainActivity.onCreate(MainActivity.kt:172) at android.app.Activity.performCreate(Activity.java:8657) at android.app.Activity.performCreate(Activity.java:8636) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4165) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4340) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2584) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8810) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:343) at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.kt:310) at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.kt:302) at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.kt:276) at androidx.lifecycle.SavedStateViewModelFactory.create(SavedStateViewModelFactory.kt:128) at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.kt:184) at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.kt:150) at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:53) at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:35) at site.leos.apps.lespas.MainActivity.getActionsPendingModel(MainActivity.kt:69) at site.leos.apps.lespas.MainActivity.onCreate(MainActivity.kt:172) at android.app.Activity.performCreate(Activity.java:8657) at android.app.Activity.performCreate(Activity.java:8636) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4165) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4340) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2584) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8810) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) Caused by: java.lang.ArrayIndexOutOfBoundsException: length=1; index=1 at site.leos.apps.lespas.helper.Tools.getLocalRoot(Tools.kt:554) at site.leos.apps.lespas.sync.ActionViewModel.using the debugger, I could see that
PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SettingsFragment.KEY_STORAGE_LOCATION, true)
is false, but thecontext.getExternalFilesDirs(null)
contains just a single entry/storage/emulated/0/Android/data/site.leos.apps.lespas/files