laurent22 / joplin

Joplin - the privacy-focused note taking app with sync capabilities for Windows, macOS, Linux, Android and iOS.
https://joplinapp.org
Other
45.33k stars 4.93k forks source link

Android filesystem sync is broken after 2.6.3 update #5779

Closed shaymagsumov closed 2 years ago

shaymagsumov commented 2 years ago

Update 20 Dec 2021: There's currently no solution to this problem. In the meantime you may downgrade to v2.5 by downloading the APK from the official repository:

https://github.com/laurent22/joplin-android/releases/download/android-v2.5.5/joplin-v2.5.5.apk


I use filesystem synchronization with path like /storage/emulated/0/Sync/Data/Joplin

After 2.6.3 update i get this error: Screenshot_20211124-094935

Could it be related to app permissions? I can choose only 'Allow access to media only' option in permission manager. Screenshot_20211124-095131

buckket commented 2 years ago

I can confirm this happens with all my Android devices (running Android 11 and Android 12) since the update.

Downgrading to the previous version made it work again.

Here’s the relevant log snippet:

11-24T11:13:56,20,"Synchronizer: ""Error: Error: Operation not permitted. Path: /storage/[redacted]/Joplin/locks/2_2_9450db2b66d24ccebc610d4adbc98838.json
Code: EUNSPECIFIED
value@index.android.bundle:1029:275
index.android.bundle:1029:4056
p@index.android.bundle:82:588
index.android.bundle:82:1893
p@index.android.bundle:82:588
o@index.android.bundle:82:1069
index.android.bundle:82:1241
u@index.android.bundle:76:157
index.android.bundle:76:866
index.android.bundle:84:1672
k@index.android.bundle:84:500
w@index.android.bundle:84:898
callReactNativeMicrotasks@index.android.bundle:84:3054
value@index.android.bundle:37:2868
index.android.bundle:37:960
value@index.android.bundle:37:2504
value@index.android.bundle:37:919
value@[native code]
value@[native code]""
laurent22 commented 2 years ago

This is probably due the Android SDK update, but not sure how (or if) that can be fixed. If someone has any idea I'd accept a pull request.

Robin-Sch commented 2 years ago

Makes the app completely useless for me, I can't sync between my phone and pc anymore

https://github.com/laurent22/joplin/issues/5639 https://github.com/laurent22/joplin/issues/5691

Timothy-Ecc19 commented 2 years ago

Add another one to the list. On Android 11 with 2.6.3 update I am no longer able to sync to my SD card so syncthing can access it. How would I go about downgrading to the previous version or can anyone think of another work around?

blueorignal commented 2 years ago

I am also experiencing the same issue when upgrading to version 2.6.3 on Android 11. Dropping back to version 2.4.3 (Google Version Code: 2097651) resolves the issue.

@laurent22 I just want to say thank you for this amazing software. It's easy to forget how much effort goes into making something like Joplin. If there is anything I can do help narrow down the issue (logs, testing, etc.) , please let me know.

@Timothy-Ecc19 you will need to uninstall Joplin and reinstall the previous version. The last official prebuild APK can be found on the root folder of Joplin's github repository, under the heading "Mobile applications", but unfortunately it is version 1.8.5.

If you want to download and side-load the last working version (2.4.3) the easiest way to obtain the APK would be via a site such as apkpure.com. < warnings> insert usual risks w.r.t. side-loading apps here < /warnings>

laurent22 commented 2 years ago

For info there's a bug in GitHub that makes it display the wrong version in the release page. Instead you need to go to the tags to see them: https://github.com/laurent22/joplin-android/tags

shaymagsumov commented 2 years ago

To downgrade you can also use Aurora Store client and choose manual download with specified version code

shaymagsumov commented 2 years ago

BTW i downgraded to 2.4.3 ans now i see different permission options: Screenshot_20211125-123736

laurent22 commented 2 years ago

Maybe they've renamed or removed the permission in this SDK update.

github-ronk commented 2 years ago

This is probably due the Android SDK update, but not sure how (or if) that can be fixed. If someone has any idea I'd accept a pull request.

@laurent22 - This Stack Overflow post seems to have the necessary information, in case you haven't seen it yet.

da2x commented 2 years ago

@laurent22 can you revert the SDK update until this is fixed?

I’m also using Syncthing.

da-sti commented 2 years ago

same thing here

android 11 (oxygenOS 11.1.1.1) joplin android 2.6.3 syncthing 1.18.3

no obvious changes happened on the android side Uninstalled joplin 2.6.3, installed 2.4.3 from apkpure, lost a bit of data in the process but it's back to functionnal now and of course, desactivated auto updates

MikhailShi commented 2 years ago

same issue since yesterday

android 11 (MIUI Global 12.5.2) joplin android 2.6.3 syncthing 1.18.3

IMG_20211126_185937

laurent22 commented 2 years ago

@laurent22 can you revert the SDK update until this is fixed?

Unfortunately no, because it's required by Google. We can't publish to the app store otherwise.

rockhazard commented 2 years ago

Happening to me too. Removing and re-creating the locks directory has no effect.

Timothy-Ecc19 commented 2 years ago

Anyone figure out what folder the "allow access to media only" gives? Maybe we could sync to there and syncthing would still be able to see it.

bensoibj commented 2 years ago

Is only Android 11 and higher affected? Maybe it is related Storage updates in Android 11. Which API level does Joplin use on Android?

bacteriostat commented 2 years ago

I am on Android 11 and I also couldn't sync after updating to 2.6.2 version. But I got a different error which I reported here #5673?

My storage location is inside Documents folder which is part of shared storage under Android 11 and maybe that's why the error is somewhat different?

ase1590 commented 2 years ago

Seems to be an android 11 issue, as upgrading from 2.4.3 to 2.6.3 results in the same issue on a Moto G Power Android 11 device. Downgrading back to 2.4.3 fixes the issue regarding filesystem sync with arbitrary folders in android.

jerseyblue commented 2 years ago

I can confirm this issue is also on android 12 (using filesystem sync target with Syncthing on a pixel 5). Downgrading to 2.4.3 resolves the issue. Just need to fiddle to stop the play store from upgrading it till the issue is resolved.

@laurent22 I'm curious if you have identified root cause and have a plan to resolve. Or a proposed workaround (e.g., should I be thinking about migrating to a different sync strategy, though I love the Joplin/Syncthing combo!)

Riolku commented 2 years ago

I mentioned some possible causes in my issue #5810. It boils down to Media access is insufficient, Joplin needs full system access to be able to work properly. I think it's a matter of changing the permission requested, and I do think it has something to do with the new android storage APIs, but I don't have much experience on android development.

I think Joplin + Syncthing is very common (I use it too), and I feel like it would be ideal to make an effort to keep that. The easy solution to this is likely to figure out what we need to change to request the proper permission.

github-ronk commented 2 years ago

I think Joplin + Syncthing is very common (I use it too), and I feel like it would be ideal to make an effort to keep that. The easy solution to this is likely to figure out what we need to change to request the proper permission.

Indeed. Even more so since the Joplin cloud-based sync solutions are too unstable to be usable (for me, according to my personal experience with Dropbox and then OneDrive syncing. YMMV)

sedlund commented 2 years ago

Device on android 11, and using Syncthing. Downloaded 2.4.3 from apkpure.com and side loaded. Sync working again.

bensoibj commented 2 years ago

As mentioned by @Riolku in #5810, a similar issue (#4122) occurred a year ago. It has been solved in PR #4134. This pull request set the flag requestLegacyExternalStorage, in this way opting out of the Scoped storage enforcement of Android 11. However, with API level 30 (which Joplin Android uses since the 2.6.3 update, more precisely, already in 2.6.1) this flag is ignored.

frederikstroem commented 2 years ago

Device on android 11, and using Syncthing. Downloaded 2.4.3 from apkpure.com and side loaded. Sync working again.

Instead of downloading from a third-party APK site, it would probably be more advisable to use the official repo specifically made for that purpose. 😊

Version 2.4.3 can be found here: https://github.com/laurent22/joplin-android/releases/tag/android-v2.4.3

meowmachine commented 2 years ago

I am experiencing the same error

Local file storage with syncthing

Downgrading to version 2.4.3 fixed it.

oliverjoa commented 2 years ago

I have the same problem here, using v.2.6.3 together with syncthing

benbaker76 commented 2 years ago

I'm having a similar issue with Joplin 2.6.4 but in Android 12 and Resilio Sync and I can't downgrade to 2.4.3.

12-05T15:12:42,30,"Synchronizer: ""Operations completed: ""
12-05T15:12:42,30,"Synchronizer: ""Sync: finished: Synchronisation finished [1638735161375]""
12-05T15:12:42,10,"Synchronizer: ""Error: Could not upgrade from version 0 to version 1: Error: File '/storage/emulated/0/Download/Sync/Data/Joplin/.sync/version.txt' does not exist and could not be created, or it is a directory. Path: /storage/emulated/0/Download/Sync/Data/Joplin/.sync/version.txt
Code: ENOENT
value@index.android.bundle:1029:275
index.android.bundle:1029:4056
p@index.android.bundle:82:588
index.android.bundle:82:1893
p@index.android.bundle:82:588
o@index.android.bundle:82:1069
index.android.bundle:82:1241
u@index.android.bundle:76:157
index.android.bundle:76:866
index.android.bundle:84:1672
k@index.android.bundle:84:500
w@index.android.bundle:84:898
callReactNativeMicrotasks@index.android.bundle:84:3054
value@index.android.bundle:37:2868
index.android.bundle:37:960
value@index.android.bundle:37:2504
value@index.android.bundle:37:919
value@[native code]
value@[native code]""
12-05T15:12:41,30,"""MigrationHandler: Releasing exclusive lock""
12-05T15:12:41,30,"""MigrationHandler: Migrating from version 0 to version 1""
12-05T15:12:41,30,"""MigrationHandler: Acquired exclusive lock:", "{"id":null,"type":2,"clientType":2,"clientId":"*removed*","updatedTime":1638735161000}""

Looking at the permissions for Joplin all it has is "Allow access to media only" but it probably needs "Allow management of all files". Screenshot_20211205-152714 Screenshot_20211205-152655

danielb2 commented 2 years ago

any workaround yet? Given the nature of this, it's rendering use of the android app useless for me since it is not synching my files at all now. Is anyone else having this severity or is it just showing the error? (iow, could I also be encountering a different issue)

Riolku commented 2 years ago

Some people have been having success downgrading the app to 2.4.3. Im having the same severity as you and others I think. We unfortunately dont have anyone taking this on :)

danielb2 commented 2 years ago

I'll try the downgrade. thank you

danielb2 commented 2 years ago

how do I downgrade? I don't see the apk for the 2.4.3 version : https://github.com/laurent22/joplin/releases/tag/v2.4.3

update found: https://apkpure.com/joplin/net.cozic.joplin/versions

jerseyblue commented 2 years ago

@danielb2, Downgrading is a suitable workaround for now -- two things to be aware of: 1) You can download it here: https://github.com/laurent22/joplin-android/releases/tag/android-v2.4.3. 1b) In the google play app, you need to set Joplin to NOT auto update. 2) Be aware that you'll lose any changes on your Android device when you downgrade. It wasn't an issue for me because I caught the lack of sync-ing early on and knew exactly what was out of date. Not sure if others have solved this issue.

danielb2 commented 2 years ago

@jerseyblue thank you for the detailed instructions and the heads up on exactly what data loss I could see. Very helpful

danielb2 commented 2 years ago

Tried installing but it says "App not installed." Any reason I'd get that?

cyphase commented 2 years ago

@danielb2 I'm guessing because the profile/settings were upgraded to the format of the version you currently have, and therefore you can't install an older version that doesn't know how to understand that later format. This is why it was mentioned that you would lose changes on mobile; you have to uninstall the app first, deleting the profile, before reinstalling.

FYI, another workaround is to change to some other sync target. I moved to WebDAV to work around this issue. I didn't have to downgrade.

benbaker76 commented 2 years ago

Tried installing but it says "App not installed." Any reason I'd get that?

When I try to downgrade to 2.4.3 I get "You can't install the app on your device."

I have no problem side-loading 2.6.4

cyphase commented 2 years ago

@headkaze See my comment above yours. https://github.com/laurent22/joplin/issues/5779#issuecomment-986386696

benbaker76 commented 2 years ago

@headkaze See my comment above yours. #5779 (comment)

I don't think it applies to me. My problem appears to be a permission issue. It cannot read the version.txt file (which exists at the correct location and contains the value "2")

roman-r-m commented 2 years ago

If my understanding is correct, according to this doc it's still possible to request access to a directory and get read/write access to it. The problem is that it requires a different (URI-based) API and I'm not aware of any react-native wrappers over the required Android API for this.

benbaker76 commented 2 years ago

I managed to downgrade to 2.4.3 by clearing storage before uninstalling but it will not read my notes (my guess is their the wrong version) so I had to upgrade back to 2.6.3.

The doc @roman-r-m links to above mentions the Download directory being restricted in Android 11 (API level 30) so I moved my Resilio Sync folder to the root.

I no longer get an error reading version.txt but instead get: Error: Operation not permitted. Path: /storage/emulated/0/Sync/Data/Joplin/locks/2_2_619d48f8508f4330b9a8c6e644074f9c.json

roman-r-m commented 2 years ago

@headkaze try the Documents directory

samuelkyl commented 2 years ago

@roman-r-m I'm getting similar problems as @headkaze with both Downloads and Documents directories. It looks like my desktop/web Joplin (2.5.12) files have version.txt as 2, and info.json as version 3, but the Android Joplin (2.6.3) is trying to do something weird to do an upgrade path starting from 0 (or is just failing to modify the files? maybe read-only?). If I delete those files I get into a bad situation where the Android app generates the files then gets stuck trying to migrate.

Also, I was trying out this thing https://developer.android.com/training/data-storage/shared/documents-files#grant-access-directory with https://reactnative.dev/docs/linking#sendintent-android like so:

Linking.sendIntent('android.intent.action.OPEN_DOCUMENT_TREE');

which is supposed to give me a file-picker where I choose which folder to grant access to, but then I hit this issue https://github.com/facebook/react-native/issues/28934 where it doesn't like me creating new activities with an Intent, which has just been fixed in the fb internal build of react-native but not the public one.

roman-r-m commented 2 years ago

@samuelkyl sending an Intent to open directory picker is only half the story (more like 20% actually). The real issue is that even if you granted permissions to a dir you can't use file-based API like Joplin does but have to work with Uri instead.

I had a PR that was supposed to use directory picker: https://github.com/laurent22/joplin/pull/4903 But again, this alone isn't going to help.

bensoibj commented 2 years ago

For the protocol: considering its age, this is currently the most commented open Joplin issue (44 comments in 14 days).

benbaker76 commented 2 years ago

@laurent22 What version of the Android SDK is Joplin 2.4.3 compiled? Can we get 2.6.4 compiled under the same SDK to side-load as a work around until the permission issue is resolved?

EDIT: I ran apktool on joplin-v2.4.3.apk and got:

sdkInfo:
  minSdkVersion: '21' (Android 5.0 Lollipop)
  targetSdkVersion: '29' (Android 10 Q)
buckket commented 2 years ago

@laurent22 What version of the Android SDK is Joplin 2.4.3 compiled? Can we get 2.6.4 compiled under the same SDK to side-load as a work around until the permission issue is resolved?

EDIT: I ran apktool on joplin-v2.4.3.apk and got:

sdkInfo:
  minSdkVersion: '21' (Android 5.0 Lollipop)
  targetSdkVersion: '29' (Android 10 Q)

Unfortunately Google Play store won’t accept updates targeting SDK 29 anymore. So that’s not an option.

benbaker76 commented 2 years ago

Unfortunately Google Play store won’t accept updates targeting SDK 29 anymore. So that’s not an option.

I'm asking for a signed version built with SDK 29 to side-load as an interim solution. Just until the permission issue is resolved.

Fabick75 commented 2 years ago

Hi, I'm following this thread for a rapid resolution, but don't seem that came very early. I've now five systems (two mobile and three desktop) in sync with syncthing and joplin on top. My question is how not to lose the modifications that I've created on one of the mobile device. Could convert in another system (like webDAV) and how? Otherwise It's necessary to wait for a resolution with SDK ?

JP1789 commented 2 years ago

Same here.. well I got 2 errors looking a bit different on 2 Android phones. Main PC runs Ubuntu. Both sync is through file system via SyncThing. Both with Joplin 2.6.3 and Android 11 Phone 1 - Sync folder has same name on the phone and on the main PC. Error: << Could not upgrade from version 0 to version 1: Error: File '/storage/emulated/0/Documents/Sync/Joplin/.sync/version.txt' does not exist and could not be created or it is a directory. Path: /storage/emulated/0/Documents/Sync/Joplin/.sync/version.txt >> Of course the said file does exist and contains "2". Joplin has all permissions possible through Android, as said in various previous posts. Phone 2 - Originally same folder name etc, so same error. I changed the sync folder then. Created a new sync with new folder on the phone, but same old folder on the main PC: so different names, but SyncThing does work and sent all the files to the phone. But Joplin cannot sync: Error: << Error: Operation not permitted. Path: /storage/emulated/0/Media/Sync/Joplin/locks/2_2_f838c189717(etc.. many digits...).json>> Phone 2 shows exactly the same permissions for Joplin as phone 1.

I do not know how to install the previous version of Joplin. I am a simple user enjoying Joplin so far. But now I panic: if I cannot sync my notes on the 2 phones with the main PC, I am in trouble. I would not want to revert to Evernote... What is the next step then?