logseq icon indicating copy to clipboard operation
logseq copied to clipboard

Can't open local folder on Android

Open aadilayub opened this issue 4 years ago • 48 comments

Describe the bug When I grant storage permissions and try to add an empty folder, nothing happens.

To Reproduce Steps to reproduce the behavior:

  1. Install latest nightly version of Logseq on Android
  2. Click on 'Grant permission' and add an empty folder as a new graph

Expected behavior Adding an empty folder generates a new graph.

Smartphone:

  • Device: Realme 5i
  • OS: Android 10
  • Browser: Chrome
  • Version: Android Nightly Release 20220106

aadilayub avatar Jan 06 '22 17:01 aadilayub

I am experiencing the same issue.

Device: Mi 10T OS: Android 11 with MIUI 12 Version: latest nightly, but also experienced this issue with previous releases

koan-github avatar Jan 07 '22 11:01 koan-github

Same here.

Device: Samsung, Galaxy J7 Star OS: Android 9 Version: Nightly Release 20220107

Philogicatician avatar Jan 07 '22 23:01 Philogicatician

Same here.

Device: Huawei P30 OS: Android 10 with EMUI 11.0.0 Version: both in 0.5.9 and Nightly Release 20220121

vivew avatar Jan 22 '22 10:01 vivew

For me, the issue disappeared after I removed a "#" from the folder name of my notes folder. Maybe some special characters in folders names cause this?

koan-github avatar Jan 23 '22 17:01 koan-github

@koan-github for me it happens when creating a graph from an empty folder too

aadilayub avatar Jan 24 '22 04:01 aadilayub

My issue resolved after choosing a file name & path containing no space characters. Thanks for the tip @koan-github

vivew avatar Jan 24 '22 06:01 vivew

The same issue on my tablet

Mi Pad 4 Plus Android 8.1.0 MIUI by xiaomi.eu 10.3 Tried versions: 0.5.5 - 0.5.9

Vault path: /storage/emulated/0/Documents/Logseq/logseq-vault/

Stacktrace (the same for all versions):

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(Unknown Source:2)
 at android.os.Handler.dispatchMessage(Unknown Source:4)
 at android.os.Looper.loop(Unknown Source:152)
 at android.os.HandlerThread.run(Unknown Source:28)
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)
 ... 5 more
Caused by: java.lang.NullPointerException: uriString
 at android.net.Uri$StringUri.<init>(Unknown Source:22)
 at android.net.Uri$StringUri.<init>(Unknown Source:0)
 at android.net.Uri.parse(Unknown Source:3)
 at com.capacitorjs.plugins.filesystem.Filesystem.getFileObject(Filesystem.java:202)
 at com.capacitorjs.plugins.filesystem.Filesystem.readdir(Filesystem.java:77)
 at com.capacitorjs.plugins.filesystem.FilesystemPlugin.readdir(FilesystemPlugin.java:270)
 ... 8 more

This vault opens correctly on my phone (OnePlus 7, Android 11, version 0.5.9)

MrModest avatar Jan 29 '22 08:01 MrModest

Version 0.6.3. crashes when choosing local folder. Granting permission seemed to work. A downgrade to version 0.6.2 seems to work though. Installed via IzzyOnDroids F-Droid repo.

ketoxime avatar Mar 14 '22 21:03 ketoxime

Downloaded the android app 0.6.4 and opened it, got the "Storage access permission" screen and if i choose that, nothing happens.

Reproduce

  1. Open Logseq
  2. "Grant permission"
  3. Choose random folder or new created one (does not show existing ones"
  4. Press "Allow access to 'Logseq'"
  5. Allow again
  6. Back into "Storage access permission" screen in the app.

The same for "Add a graph".

Mobile Info Device: Xiaomi Mi 9 Android: 10 Logseq: 0.6.4 (F-Droid through IzzySoft Repository)

Additional Usally i get an android-window for asking the permission to store files on the device - this window does not appear at all. But "android settings > apps > permissions" -> "Access and change files on internal storage" is granted with "Always allow" as well, so i might have allowed this the first time i opened the app.

natrius avatar Mar 21 '22 06:03 natrius

Can report the same problem when trying to open a synced Nextcloud folder. Folder access is granted, but, I end up on the start page again after selecting the folder. The path is "/Android/media/com.nextcloud.client/nexcloud/[email protected]%2Fnextcloud/ Opening a folder path without special characters works. Could it be the "@" or URL-encoded "/" in the path?

Device: Xiaomi Mi 8 lite Android: 11 (lineageOS) Logseq: 0.6.5 (Google Playstore)

joebroesel avatar Mar 28 '22 08:03 joebroesel

There are lots of reports mentioning this issue. It would be good to centralise them here.

https://github.com/logseq/logseq/issues/4936 https://github.com/logseq/logseq/issues/5038 https://github.com/logseq/logseq/issues/4628 https://github.com/logseq/logseq/issues/4993 https://github.com/logseq/logseq/issues/3972

aadilayub avatar Apr 24 '22 17:04 aadilayub

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 avatar Apr 24 '22 17:04 aadilayub

I manged to get it working btw. - when i press "Grant permissions" it does not show anything in that folder, even if i create a logseq folder (but, it exists, i checked). What i noticed, if i press "phone" on the left side in the file-browser and manually navigate to "Download" again, i can see all the folders and i can see the "Logseq"-Folder as well. If i choose the folder now - it works for me.

natrius avatar Apr 24 '22 18:04 natrius

I manged to get it working btw. - when i press "Grant permissions" it does not show anything in that folder, even if i create a logseq folder (but, it exists, i checked). What i noticed, if i press "phone" on the left side in the file-browser and manually navigate to "Download" again, i can see all the folders and i can see the "Logseq"-Folder as well. If i choose the folder now - it works for me.

It doesn't get that far for me. After I grant file access permission, and click choose folder, it immediately crashes.

Here's a screen recording: https://photos.app.goo.gl/ZXjWMQUZHy5pKtGw9

aadilayub avatar Apr 25 '22 07:04 aadilayub

This issue is about, and i quote your initial comment "When I grant storage permissions and try to add an empty folder, nothing happens." and not "the app crashes".

These are two different issues in my opinion.

natrius avatar Apr 25 '22 07:04 natrius

I got a similar issue.

Reproduce

1. Install a brand new LogSeq / Clear all app user data and cache
2. Choose a folder for my graph
3. Allow the permission request
4. Navigate to my storage root first then browse and select a previously created / newly created folder as the target.
5. Starting to load. ("Parsing file" on the top left will appear for a brief moment)
6. Freeze, then "Logseq has stopped working" pops up.  

and there is an alternative result if, in the 4th step, I choose as the file exploring app default (it will be located at the exact folder I chose last time before current data clear&reset )

4. Select the default (right as last open) folder without navigating out first
5. Nothing happened, nothing loaded (the "choose a folder" UI is still there.)  

The folder I use was all under "Downloads" or "Pictures" default folder created by the system, might have something to do with this?

Device Info:

App Version: 0.6.6 on Android.
Android Version: 8.0.0
Device: ASUS_X00PD
Installed via direct downloaded .apk file from GitHub release.
I've done some tests and found such problems don't exist in 0.5.9, 0.6.2, and started to appear in 0.6.3.

SkyLull avatar Apr 25 '22 14:04 SkyLull

This issue is about, and i quote your initial comment "When I grant storage permissions and try to add an empty folder, nothing happens." and not "the app crashes".

These are two different issues in my opinion.

You might be right. However, because both issues are giving the same stack trace, they may have the same underlying cause.

aadilayub avatar Apr 26 '22 17:04 aadilayub

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

Update: 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.

aadilayub avatar Apr 26 '22 17:04 aadilayub

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

Sorry, but my exception is quite different, and I get it when I choose the folder. And I choose it via system file manager, not third party.

My exception is

java.lang.NullPointerException: uriString

but your is

android.content.ActivityNotFoundException: No Activity found to handle Intent

MrModest avatar Apr 26 '22 18:04 MrModest

It's interesting. When I tried to choose folder like /storage/emulated/0/Logseq (or Download folder), I got a new stacktrace:

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(Unknown Source:2)
	at android.os.Handler.dispatchMessage(Unknown Source:4)
	at android.os.Looper.loop(Unknown Source:152)
	at android.os.HandlerThread.run(Unknown Source:28)
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)
	... 5 more
Caused by: java.lang.NoSuchMethodError: No direct method <init>(Ljava/io/File;I)V in class Landroid/os/FileObserver; or its super classes (declaration of 'android.os.FileObserver' appears in /system/framework/framework.jar)
	at com.logseq.app.FsWatcher$SingleFileObserver.<init>(FsWatcher.java:203)
	at com.logseq.app.FsWatcher.watch(FsWatcher.java:60)
	... 8 more

But for /storage/emulated/0/Documents folder error still the previous one

MrModest avatar Apr 26 '22 18:04 MrModest

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

Sorry, but my exception is quite different, and I get it when I choose the folder. And I choose it via system file manager, not third party.

My exception is

java.lang.NullPointerException: uriString

but your is

android.content.ActivityNotFoundException: No Activity found to handle Intent

My bad, you're right. I didn't read the stacktrace carefully.

aadilayub avatar Apr 27 '22 11:04 aadilayub

Android 9 - Logseq had opened before but I had deleted it a week or so ago. Tried to reinstall it and use it yesterday and I am facing the same issue the app crashes as soon as I select the folder. I tried 0.6. 0.6.5 0.6.4

On another phone with Android 11 it's working

meldarionqeusse avatar Apr 28 '22 16:04 meldarionqeusse

I manged to get it working btw. - when i press "Grant permissions" it does not show anything in that folder, even if i create a logseq folder (but, it exists, i checked). What i noticed, if i press "phone" on the left side in the file-browser and manually navigate to "Download" again, i can see all the folders and i can see the "Logseq"-Folder as well. If i choose the folder now - it works for me.

This worked for me! Thanks.

cheew avatar Apr 28 '22 21:04 cheew

I manged to get it working btw. - when i press "Grant permissions" it does not show anything in that folder, even if i create a logseq folder (but, it exists, i checked). What i noticed, if i press "phone" on the left side in the file-browser and manually navigate to "Download" again, i can see all the folders and i can see the "Logseq"-Folder as well. If i choose the folder now - it works for me.

Works for me as well! Thank you!!

neko-cha avatar Apr 29 '22 02:04 neko-cha

got same issue: LinageOS 16.0 F-Droid Izzy repo Logseq 0.6.7 folder in /storage/emulated/0/Documents

hornyjailfish avatar May 01 '22 11:05 hornyjailfish

I have a similar issue when trying to open a Nextcloud synced folder.

ubuntudroid avatar May 01 '22 12:05 ubuntudroid

Looks like a bug in capacitors file picker API wrapper, but I didn't find any related report in their GitHub repository... 🤔

Caused by: java.lang.NullPointerException: uriString
        at android.net.Uri$StringUri.<init>(Uri.java:507)
        at android.net.Uri$StringUri.<init>(Uri.java:497)
        at android.net.Uri.parse(Uri.java:469)
        at com.capacitorjs.plugins.filesystem.Filesystem.getFileObject(Filesystem.java:202)
        at com.capacitorjs.plugins.filesystem.Filesystem.readdir(Filesystem.java:77)
        at com.capacitorjs.plugins.filesystem.FilesystemPlugin.readdir(FilesystemPlugin.java:270)
        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) 
        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) 

ubuntudroid avatar May 01 '22 12:05 ubuntudroid

I still got this issue with the latest update. I'm forced to stay with 0.6.2 for now. Any version above that crashed immediately when loading the graph. One thing that I notice is you cannot place the graph in a folder deeper than 2 levels from the storage root directory. E.g.:

  • /sdcard/Logseq/ is OK.
  • /sdcard/Logseq/Personal/ is OK
  • /sdcard/Documents/Logseq/Personal/ or anything deeper than that is not OK.

Device: Samsung S8 SM-GM950FD Android: 9 with One UI 1.0 (Stock Samsung Android) Logseq: 0.6.2 (works with above issue), 0.6.3..0.6.8 (Crashed when loading graph)

efade avatar May 12 '22 03:05 efade

I'm also having this problem. Sometimes the Android and desktop become out of sync re indexing doesn't work. I clear cache and then try to open local folder (the same one I was using before) - Allow access permission granted, then I just get returned to the open local folder screen - essentially nothing has happened. Kind of renders the whole thing useless.

dannymagnus avatar May 18 '22 07:05 dannymagnus

I still got this issue with the latest update. I'm forced to stay with 0.6.2 for now. Any version above that crashed immediately when loading the graph. One thing that I notice is you cannot place the graph in a folder deeper than 2 levels from the storage root directory. E.g.:

  • /sdcard/Logseq/ is OK.
  • /sdcard/Logseq/Personal/ is OK
  • /sdcard/Documents/Logseq/Personal/ or anything deeper than that is not OK.

Device: Samsung S8 SM-GM950FD Android: 9 with One UI 1.0 (Stock Samsung Android) Logseq: 0.6.2 (works with above issue), 0.6.3..0.6.8 (Crashed when loading graph)

I believe I found a possible cause of issues for Android versions older than Android 10: https://github.com/logseq/logseq/commit/5dd0234b9a73bb663a636d0a0b743fe6a717030a#r74153137

However, it seems there may be multiple different issues at play in the comments here. I'm running Android 9 on a Samsung Note 8 and I experience this same behavior.

MattHulse avatar May 21 '22 00:05 MattHulse