logseq / logseq

A privacy-first, open-source platform for knowledge management and collaboration. Download link: http://github.com/logseq/logseq/releases. roadmap: http://trello.com/b/8txSM12G/roadmap
https://logseq.com
GNU Affero General Public License v3.0
30.26k stars 1.77k forks source link

Android Beta 0.5.9 crashes when granting folder permission #3972

Closed TimLamoureux closed 1 year ago

TimLamoureux commented 2 years ago

I just started using Logseq Android Beta version 0.5.9 and it crashes whenever I attempt to grant Storage Access Permission. This happens before Logseq attempts to load the graph and can be reproduced on both the main device memory and an SD card.

The first time it crashes directly to the desktop and on subsequent crashes, it informs that Logseq keeps stopping with options for App info and Close app.

App info shows that Logseq has storage permissions allowed. When I try to open either of an existing graph or an empty folder, the application still crashes.

Device: Samsung Galaxy S9 SM-G960W Android 10 with the November 2021 security patch

Other users are affected by this issue in the Discord android-beta channel on 2022-01-20 11:20 AM MST

luxpir commented 2 years ago

Similar issue, only happens at next stage - when adding a graph, even an empty local file, after giving storage permissions, the app closes to home screen. Bringing it back up restarts it.

I did merge my SD card into system storage last year, but these graphs I'm adding are not using it afaict.

aadilayub commented 2 years ago

This issue might be a duplicate of https://github.com/logseq/logseq/issues/3789

sobeitnow0 commented 2 years ago

Same here.

Device: Xiaomi Mi 8 lite OS: Android 10 QKQ1.190910.002 MIUI: 12.0.3 Version: both in 0.5.9 and Nightly Release 20220121

TimLamoureux commented 2 years ago

This issue might be a duplicate of #3789

Both issues are similar but not exactly the same. In #3972 (this one), Logseq exits with an error when granting permissions whereas in #3789 the app is unable to open a new graph but does not seem like it crashes. The recommendations of #3789 to remove any special character from the graph path do not improve #3972.

I tested on 0.5.8 and the app crashed when loading an empty graph at /Documents/logseqtest but it loads the empty graph if it is located at /logseqtest. is a placeholder for the (hidden) path where Android stores a user's files.

Back to 0.5.9 and it loads a graph at /logseqtest properly. Something seems wrong with subdirectories for me.

luxpir commented 2 years ago

Same. Can load /logseqtest when created straight under the phone's "home" directory (that has Android, Documents, Download etc. in it) but can't load my existing files under Documents/Notes.

mmBesar commented 2 years ago

Same problem under Android 10, can not load folders in sub directory, it has to be a main folder!
Running the latest testing version!
I did not have this problem under Android 11, with rhe same device and setup.

EDIT : my Android 11 experience.
EDIT : correct spelling.

Co-7 commented 2 years ago

Any news about this issue ?

TimLamoureux commented 2 years ago

Besides the nightly builds, there hasn't been a new release of the Android APK. The issue is still present to this day and the workaround is to store your graph in the top folder of your storage location and not a sub folder.

Co-7 commented 2 years ago

And how do I do that ? by clicking on open a local directory or grant permissions it crashes

TimLamoureux commented 2 years ago

IHey Co-7,

First let's make sure your data is backed up if you already have a graph on your phone. Then you can try clearing your Logseq application cache and storage to see if that helps.

Which version of Logseq are you using? Make sure you've updated to the latest non-nightly release Desktop/Android APP 0.5.9 (Beta Testing)

What phone model and Android version? I have only tried on Android 10 on a Galaxy S9 (PS: I'm not part of the dev team)

Just to clarify, does it crash when you click the Grant Permission button or when you try to select a folder in the file browser that opens after clicking the button? Because I was playing around, I gave Storage access permission to Logseq through the Phone Settings under Apps > Logseq > Permissions > Storage. That may help you to get further and be able to load a graph in the root of your storage location.

Co-7 commented 2 years ago

Hi, so I already did by giving permission via the settings but after when I click on open directory it crashes the same way 💁

I have a Oneplus 6T running Android 10 and the version of logseq you said 😅

llcc commented 2 years ago

Hi guys, thanks for your reporting. Android app crash has been fixed in the nightly release. You can download it here and see if your issue still persists.

gejianxin commented 2 years ago

Same problem exists on 0.6.1 nightly build

mmBesar commented 2 years ago

Sorry, not solved for me!

thebiblelover7 commented 2 years ago

@llcc The app still crashes on the newest version whenever I select a directory that is on my SD-card. When I select one that is on internal storage, it works fine.

MrModest commented 2 years ago

Still the same.

Problem could have common with https://github.com/logseq/logseq/issues/3789

Because I see the same stacktrace

ketoxime commented 2 years ago

With version 0.6.3. I also had crashes related to granting folder permission/folder selection. For me a downgrade to version 0.6.2. seems to work. Installed via IzzyOnDroids F-Droid Repo. Hope this helps.

daraul commented 2 years ago

I'm having this problem on 0.6.4. 0.6.2 didn't work either. I tried connecting to my existing org-mode directory within termux and got the same crash.

bigFin commented 2 years ago

Still crashing on 0.6.5

aadilayub commented 2 years ago

Pasting my comment from #3789. I still feel it is describing the same problem.


I have now experienced this issue on multiple phones, on Android 10, 11, and 12, across multiple versions of Logseq from 0.6.2 up to the latest nightly. Am currently experiencing it on a Google Pixel 5, where adding a graph worked initially but mysteriously stopped working after a reinstall. It takes place with empty graphs, and with large graphs, and after removing special characters from file names. It also takes place with graphs placed in the Android home folder and in subdirectories.

I made an attempt at fishing out the error message from the crash through logcat. It appears to be the same as the one shared by @MrModest


FATAL EXCEPTION: CapacitorPlugins
Process: com.logseq.app, PID: 7908
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at com.getcapacitor.Bridge.lambda$callPluginMethod$0$Bridge(Bridge.java:601)
    at com.getcapacitor.-$$Lambda$Bridge$25SFHybyAQk7zS27hTVXh2p8tmw.run(Unknown Source:8)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:121)
    at com.getcapacitor.Bridge.lambda$callPluginMethod$0$Bridge(Bridge.java:592)
    ... 6 more
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.OPEN_DOCUMENT_TREE cat=[android.intent.category.DEFAULT] }
    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2117)
    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1762)
    at android.app.Activity.startActivityForResult(Activity.java:5407)
    at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:584)
    at androidx.core.app.ActivityCompat.startActivityForResult(ActivityCompat.java:234)
    at androidx.activity.ComponentActivity$2.onLaunch(ComponentActivity.java:218)
    at androidx.activity.result.ActivityResultRegistry$2.launch(ActivityResultRegistry.java:162)
    at androidx.activity.result.ActivityResultLauncher.launch(ActivityResultLauncher.java:47)
    at com.getcapacitor.Plugin.startActivityForResult(Plugin.java:181)
    at com.logseq.app.FolderPicker.pickFolder(FolderPicker.java:40)
    ... 9 more
aadilayub commented 2 years ago

Here is a screen recording of the bug:

https://photos.app.goo.gl/ZXjWMQUZHy5pKtGw9

aadilayub commented 2 years ago

Pasting my comment from #3789. I still feel it is describing the same problem.


I have now experienced this issue on multiple phones, on Android 10, 11, and 12, across multiple versions of Logseq from 0.6.2 up to the latest nightly. Am currently experiencing it on a Google Pixel 5, where adding a graph worked initially but mysteriously stopped working after a reinstall. It takes place with empty graphs, and with large graphs, and after removing special characters from file names. It also takes place with graphs placed in the Android home folder and in subdirectories.

I made an attempt at fishing out the error message from the crash through logcat. It appears to be the same as the one shared by @MrModest


FATAL EXCEPTION: CapacitorPlugins
Process: com.logseq.app, PID: 7908
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
  at com.getcapacitor.Bridge.lambda$callPluginMethod$0$Bridge(Bridge.java:601)
  at com.getcapacitor.-$$Lambda$Bridge$25SFHybyAQk7zS27hTVXh2p8tmw.run(Unknown Source:8)
  at android.os.Handler.handleCallback(Handler.java:938)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loopOnce(Looper.java:201)
  at android.os.Looper.loop(Looper.java:288)
  at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: java.lang.reflect.InvocationTargetException
  at java.lang.reflect.Method.invoke(Native Method)
  at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:121)
  at com.getcapacitor.Bridge.lambda$callPluginMethod$0$Bridge(Bridge.java:592)
  ... 6 more
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.OPEN_DOCUMENT_TREE cat=[android.intent.category.DEFAULT] }
  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2117)
  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1762)
  at android.app.Activity.startActivityForResult(Activity.java:5407)
  at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:584)
  at androidx.core.app.ActivityCompat.startActivityForResult(ActivityCompat.java:234)
  at androidx.activity.ComponentActivity$2.onLaunch(ComponentActivity.java:218)
  at androidx.activity.result.ActivityResultRegistry$2.launch(ActivityResultRegistry.java:162)
  at androidx.activity.result.ActivityResultLauncher.launch(ActivityResultLauncher.java:47)
  at com.getcapacitor.Plugin.startActivityForResult(Plugin.java:181)
  at com.logseq.app.FolderPicker.pickFolder(FolderPicker.java:40)
  ... 9 more

It seems like the key part in this stack trace is the "No activity found to handle intent".

This is the function it references in the FolderPicker.java file:

https://github.com/logseq/logseq/blob/master/android/app/src/main/java/com/logseq/app/FolderPicker.java#L36-L47

After reading the file, it looks like the intent it can't find an activity for is ACTION_OPEN_DOCUMENT_TREE.

I did a Google search for "No activity found" errors related to this intent, and it seems like a common issue.

It's probably not related to the Android version, because this intent was introduced in Android Lollipop, so it should work on all recent devices.

aadilayub commented 2 years ago

I figured out what was causing this. On both my phones, I'd uninstalled the stock file manager app and replaced it with a third party file manager. The intent probably only plugins into the stock file manager, and when it isn't present, gives an error. After I reset my phone to factory settings, I was able to add a folder and use logseq.

It's possible that the reason for this crash on other phones is that the manufacturer OS doesn't ship the AOSP file manager/file picker that is required by this intent.

dznsm commented 2 years ago

It's possible that the reason for this crash on other phones is that the manufacturer OS doesn't ship the AOSP file manager/file picker that is required by this intent.

Most Androids can handle these intents fine as its a requirement of the Compatibility Test Suite which all Androids that are licensing Play Services need to pass (otherwise they cant call themselves Android).

i think pretty much everywhere uses the AOSP Files app (or a fork) - com.android.documentsui - even if they have their own file manager app and they hide documentsUI away in the background and it is just used for stuff like handling the file and directory intent pickers.

I think the 'ultimate' solution to this issue, which gives users more control and better interoperability with other apps, is for logseq to fully embrace the Android Storage Access Framework. A graph could optionally (or by default?) be created in the private storage of the logseq app, and a document provider implemented. This would provide the user with much more control over their data - the ability to grant fine grained access to any file or directories to other apps. I wrote about this in more detail over at the logseq forum. Votes there will hopefully encourage implementation. https://discuss.logseq.com/t/use-storage-access-framework-for-best-privacy-compatibility/6462

nicolasmarc1 commented 2 years ago

same problem with pocophone f1

andelf commented 1 year ago

This is fixed in the nightly version. by #6315 Feel free to reopen if the problem still exists.

ayush19283 commented 1 month ago

@dznsm can you pl tell what;s the final fix is . I am still struggling with the problem. Please help.