App crashes on opening of File Browser (Android 11) #30

Closed
opened 1 year ago by dial25sd · 10 comments

Hey there,

since the {}/[] bug was affecting me quite severely, I was looking forward to v2 of this app.
Tried it yesterday with a debug build, but the app keeps crashing on the opening of the file browser in the preferences.

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: de.micmun.android.nextcloudcookbook.debug, PID: 18814
    android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.OPEN_DOCUMENT_TREE (has extras) }
        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2258)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1914)
        at android.app.Activity.startActivityForResult(Activity.java:5326)
        at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:675)
        at android.app.Activity.startActivityForResult(Activity.java:5284)
        at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:662)
        at com.anggrayudi.storage.ActivityWrapper.startActivityForResult(ActivityWrapper.kt:22)
        at com.anggrayudi.storage.SimpleStorage.openFolderPicker(SimpleStorage.kt:150)
        at de.micmun.android.nextcloudcookbook.ui.preferences.PreferenceFragment.chooseFolder(PreferenceFragment.kt:140)
        at de.micmun.android.nextcloudcookbook.ui.preferences.PreferenceFragment.onPreferenceClick(PreferenceFragment.kt:128)
        at androidx.preference.Preference.performClick(Preference.java:1184)
        at androidx.preference.Preference.performClick(Preference.java:1166)
        at androidx.preference.Preference$1.onClick(Preference.java:181)
        at android.view.View.performClick(View.java:7520)
        at android.view.View.performClickInternal(View.java:7489)
        at android.view.View.access$3600(View.java:826)
        at android.view.View$PerformClick.run(View.java:28555)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:245)
        at android.app.ActivityThread.main(ActivityThread.java:8004)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)
I/Process: Sending signal. PID: 18814 SIG: 9

Seems to be somewhat related to the storage library used. Since I'm not super deep into native Android development, I opened this issue. If you give me a hint or two, I might be willing to try to fix it myself tho ;)

Crashed on my Oneplus Nord (Android 11), worked well on a Pixel 4 AVD (Android 11 too).

Stay safe!
dial25sd

Hey there, since the {}/[] bug was affecting me quite severely, I was looking forward to v2 of this app. Tried it yesterday with a debug build, but the app keeps crashing on the opening of the file browser in the preferences. ``` E/AndroidRuntime: FATAL EXCEPTION: main Process: de.micmun.android.nextcloudcookbook.debug, PID: 18814 android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.OPEN_DOCUMENT_TREE (has extras) } at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2258) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1914) at android.app.Activity.startActivityForResult(Activity.java:5326) at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:675) at android.app.Activity.startActivityForResult(Activity.java:5284) at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:662) at com.anggrayudi.storage.ActivityWrapper.startActivityForResult(ActivityWrapper.kt:22) at com.anggrayudi.storage.SimpleStorage.openFolderPicker(SimpleStorage.kt:150) at de.micmun.android.nextcloudcookbook.ui.preferences.PreferenceFragment.chooseFolder(PreferenceFragment.kt:140) at de.micmun.android.nextcloudcookbook.ui.preferences.PreferenceFragment.onPreferenceClick(PreferenceFragment.kt:128) at androidx.preference.Preference.performClick(Preference.java:1184) at androidx.preference.Preference.performClick(Preference.java:1166) at androidx.preference.Preference$1.onClick(Preference.java:181) at android.view.View.performClick(View.java:7520) at android.view.View.performClickInternal(View.java:7489) at android.view.View.access$3600(View.java:826) at android.view.View$PerformClick.run(View.java:28555) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:245) at android.app.ActivityThread.main(ActivityThread.java:8004) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978) I/Process: Sending signal. PID: 18814 SIG: 9 ``` Seems to be somewhat related to the storage library used. Since I'm not super deep into native Android development, I opened this issue. If you give me a hint or two, I might be willing to try to fix it myself tho ;) Crashed on my Oneplus Nord (Android 11), worked well on a Pixel 4 AVD (Android 11 too). Stay safe! dial25sd
Owner

Thats not good.
Do you have no file manager installed?

I will look as soon as possible, how to fix this.

Thats not good. Do you have no file manager installed? I will look as soon as possible, how to fix this.
Poster

Sure I do. Got the OnePlus file manager as well as Amaze from F-Droid installed.

Sure I do. Got the OnePlus file manager as well as Amaze from F-Droid installed.
Owner

Have you other apps (e.g. Nextcloud client or others) with which you can open a folder picker dialog?
I read about the cause with deactivated files/document app or a problem with the android os, but I find no way to reproduce it with an emulator.
Normal systems always have a dialog to pick a folder.

The library for storage access uses the storage access framework (SAF), which should work on all android devices.
It surprises me, that there can be a case without handler for picking a directory.
The action.OPEN_DOCUMENT_TREE is a standard action since Android 5.0.

Have you other apps (e.g. Nextcloud client or others) with which you can open a folder picker dialog? I read about the cause with deactivated files/document app or a problem with the android os, but I find no way to reproduce it with an emulator. Normal systems always have a dialog to pick a folder. The library for storage access uses the storage access framework (SAF), which should work on all android devices. It surprises me, that there can be a case without handler for picking a directory. The action.OPEN_DOCUMENT_TREE is a standard action since Android 5.0.
MicMun added the
bug
label 1 year ago
Owner

Have you update from 1.4.0 or is it a new clean install?

If it is an update: Can you try to delete the data of the app and set it up again?
Perhaps it is a permission problem, which is wrong cached and cause the fail of open a folder picker.
It's only an idea.

Have you update from 1.4.0 or is it a new clean install? If it is an update: Can you try to delete the data of the app and set it up again? Perhaps it is a permission problem, which is wrong cached and cause the fail of open a folder picker. It's only an idea.
Poster

First of all, sorry for the late response.

Apparently the thing is: my OP Nord came with 2 file managers installed. Since I'm not a huge fan of all that Google stuff, I disabled the Google file manager (still kept the Oneplus file manager tho).
Apparently, the OP file manager does not handle OPEN_DOCUMENT_TREE. Neither does Amaze.
Re-enabling the Google file manager hence did the trick. However, with v1.4 of the cookbook app, the file picker worked perfectly well (also with disabled Google file manager).

I might do a PR this week for proper handling of this error. Nevertheless, I clearly see that this isn't primarily an issue of your app.

First of all, sorry for the late response. Apparently the thing is: my OP Nord came with 2 file managers installed. Since I'm not a huge fan of all that Google stuff, I disabled the Google file manager (still kept the Oneplus file manager tho). Apparently, the OP file manager does not handle OPEN_DOCUMENT_TREE. Neither does Amaze. Re-enabling the Google file manager hence did the trick. However, with v1.4 of the cookbook app, the file picker worked perfectly well (also with disabled Google file manager). I might do a PR this week for proper handling of this error. Nevertheless, I clearly see that this isn't primarily an issue of your app.
Owner

No problem, I also need some time to answer.
That is really awkward.
I looked at the implentation of the simplestorage library, it uses some new Intent since Android 10 or 11.
When I implement server synchronisation I take a closer look to the folder picker.

For now, I will catch the exception and show a error message, so the app should not crash.

No problem, I also need some time to answer. That is really awkward. I looked at the implentation of the simplestorage library, it uses some new Intent since Android 10 or 11. When I implement server synchronisation I take a closer look to the folder picker. For now, I will catch the exception and show a error message, so the app should not crash.
Poster

Alright, I'm gonna have a short look into it and do a PR (if my Kotlin skills haven't completely vanished yet).

Alright, I'm gonna have a short look into it and do a PR (if my Kotlin skills haven't completely vanished yet).
Poster

As I'm about to setup the project locally: Is there a reason the project is not using gradle wrapper?

As I'm about to setup the project locally: Is there a reason the project is not using gradle wrapper?
Owner

You don't need to do that, I am able to make it myself.
The error handling is in the development locally.
If I understand right, you also want to fix the crash and show an error message instead?

And the gradle wrapper is my personal lazyness, because the local installation is updated automatically. I will change that the next iteration.

You don't need to do that, I am able to make it myself. The error handling is in the development locally. If I understand right, you also want to fix the crash and show an error message instead? And the gradle wrapper is my personal lazyness, because the local installation is updated automatically. I will change that the next iteration.
MicMun self-assigned this 1 year ago
MicMun added this to the 2.1.0 milestone 1 year ago
Poster

I know you're able to - your app definitely demonstrates it! :)
Alright, I'm gonna dig into another issue then.

Thanks a lot, keep on the good work!

I know you're able to - your app definitely demonstrates it! :) Alright, I'm gonna dig into another issue then. Thanks a lot, keep on the good work!
MicMun closed this issue 1 year ago
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: MicMun/nextcloud-cookbook#30
Loading…
There is no content yet.