Closed 77 closed 2 years ago
Cannot list the apps data directory because it's not debuggable.
1|sargo:/ $ run-as com.example.companion_app run-as: package not debuggable: com.example.companion_app
Didn't expect anyone to use this script so early in development :o
I noticed the exact same issue on my Android 6.0 test device (albeit the app works just fine on my Android 10 phone, odd). The problem is caused by the companion app not getting sufficient permissions to save contacts to the internal storage. Even though it has checks for this, it seems that the permission handler library says they've been granted anyway.
I can build a debug .apk for you if needed.
Some questions before we continue:
I've changed the library used for handling permissions and the app is working without problems on my phone running Android 10. Try installing it (download from Releases, but deleting the .apk downloaded by the script should also work), press "Export Data" and check if a directory called linux-android-backup-temp
is created in the internal storage.
I've been looking for a way to backup everything and ran across your repo yesterday. Happy to help you with testing.
I'm on a Pixel 3a running Android 11. My hunch is the files were stored in internal app storage instead the the absolute path you specified but I couldn't confirm without debugging the companion app. I'm not familiar with Flutter or Dart but they seem straightforward enough that I can contribute. By the way I'm running your app on Win10 under WSL2. Took a little while to get ADB working but the script runs fine under WSL.
I had to manually uninstall the companion app because adb was giving an error about version mismatch. Once I did that the app ran and it did ask for permissions to contacts and media. However, I'm still seeing the same error.
Exporting contacts (as vCard).
adb: error: failed to stat remote object '/storage/emulated/0/linux-android-backup-temp': No such file or directory
Checked the filesystem and there is no file there.
sargo:/ $ ls -al /storage/emulated/0/
total 133
drwxrwx--- 4 root everybody 3488 2021-03-12 06:22 .backups
-rw-rw---- 1 root everybody 36 2019-08-07 14:57 .profig.os
drwxrwx--- 2 root everybody 3488 2019-05-23 21:05 Alarms
drwxrwx--- 5 root everybody 3488 2019-09-24 15:39 Android
drwxrwx--- 2 root everybody 3488 2020-09-23 18:09 Audiobooks
drwxrwx--- 2 root everybody 3488 2019-08-16 15:44 Books
drwxrwx--- 2 root everybody 3488 2019-08-05 15:35 Cardboard
drwxrwx--- 4 root everybody 3488 2020-07-12 14:17 DCIM
drwxrwx--- 3 root everybody 3488 2021-04-13 15:41 Documents
drwxrwx--- 4 root everybody 4096 2021-11-20 11:48 Download
drwxrwx--- 3 root everybody 3488 2019-12-04 13:19 Movies
drwxrwx--- 3 root everybody 3488 2019-09-28 09:18 Music
drwxrwx--- 2 root everybody 3488 2019-05-23 21:05 Notifications
drwxrwx--- 12 root everybody 3488 2021-05-06 13:07 Pictures
drwxrwx--- 2 root everybody 3488 2020-03-03 17:02 Podcasts
drwxrwx--- 2 root everybody 3488 2019-05-23 21:05 Ringtones
drwxrwx--- 2 root everybody 3488 2021-12-23 08:10 com.wondershare.mobilego_ACache
drwxrwx--- 3 root everybody 3488 2019-05-28 08:11 data
drwxrwx--- 2 root everybody 3488 2019-08-16 15:44 kindle
drwxrwx--- 3 root everybody 3488 2019-12-11 17:04 netease
-rw-rw---- 1 root everybody 69369 2020-09-22 04:00 ota
drwxrwx--- 2 root everybody 3488 2019-08-05 10:03 panoramas
sargo:/ $
Cannot check the apps private storage because it's not debuggable.
sargo:/ $ run-as com.example.companion_app
run-as: package not debuggable: com.example.companion_app
running Android 11
That's the problem. I've heard that newer versions of Android add very strict restrictions to prevent apps from having full access to the internal storage.
I'll have to rewrite the file saving logic to make use of the newer SAF API. While it'd make things a lot inconvenient (as the user would need to manually tell the script where the contacts were saved), it'll guarantee stability and compatibility with newer versions of Android. Give me a few hours :)
Cannot check the apps private storage because it's not debuggable.
The app doesn't save anything to its private storage.
I found a way to make the app work for Android 11 without using SAF, but it's a little harder than I expected it to be (need to find a way to make it compatible with older versions). The update will be released tomorrow (assuming you're in Europe).
Just committed a change that should allow for the app to work on Android 11 without SAF. I don't have any devices running Android 11, so I'd appreciate it if you'd test the app again.
Edit: adb was giving an error about version mismatch
- I committed a fix for this, git pull
the changes and try again.
This time when I ran the companion app I was prompted to let it manage all files. I enabled that but the script still fails to find the folder on the device
Exporting contacts (as vCard).
adb: error: failed to stat remote object '/storage/emulated/0/linux-android-backup-temp': No such file or directory
I opened a shell and no folder was created under /storage/emulated/0/.
sargo:/storage/emulated/0 $ cd linux-android-backup-temp
/system/bin/sh: cd: /storage/emulated/0/linux-android-backup-temp: No such file or directory
I'm quite lost to be honest. Could you try installing Flutter, running the app in Android Studio and sending the debug logs?
What logs are you looking for specifically. I ran the app in the debugger and everything appears to run fine. No errors or exceptions are thrown but the files simply are not where you expect them.
That's really odd...
I wanted to avoid this, but I'll try to reproduce this myself on a virtual device. I'll be able to download the system image files in a week though, since I'm on a data capped connection.
Could you look into #2 in the meanwhile?
Edit: Just set up Android Studio, Flutter and the virtual device on a new computer. Expect to see an update tomorrow.
I'm sorry that this took so long. The problem was caused by the app not creating the linux-android-backup-temp
directory, making the whole script silently fail. I missed this bug when testing on my main device because the folder was created before this bug was introduced.
A fix has been pushed to the repository and the patched app should be already built by the time you're reading this. Let me know if I can close this issue.
Appears to have solved the problem.
Exporting contacts (as vCard).
/storage/emulated/0/linux-android-backup-temp/: 130 files pulled, 0 skipped. 0.2 MB/s (373483 bytes in 1.663s)
Removing temporary files created by the companion app.
rm '/storage/emulated/0/linux-android-backup-temp/linux-android-backup-contact-0.vcf'
rm '/storage/emulated/0/linux-android-backup-temp/linux-android-backup-contact-1.vcf'
rm '/storage/emulated/0/linux-android-backup-temp/linux-android-backup-contact-11.vcf'
rm '/storage/emulated/0/linux-android-backup-temp/linux-android-backup-contact-3.vcf'
rm '/storage/emulated/0/linux-android-backup-temp/linux-android-backup-contact-4.vcf'
rm '/storage/emulated/0/linux-android-backup-temp/linux-android-backup-contact-16.vcf'
rm '/storage/emulated/0/linux-android-backup-temp/linux-android-backup-contact-13.vcf'
rm '/storage/emulated/0/linux-android-backup-temp/linux-android-backup-contact-17.vcf'
rm '/storage/emulated/0/linux-android-backup-temp/linux-android-backup-contact-8.vcf'
rm '/storage/emulated/0/linux-android-backup-temp/linux-android-backup-contact-5.vcf'
rm '/storage/emulated/0/linux-android-backup-temp/linux-android-backup-contact-6.vcf'
rm '/storage/emulated/0/linux-android-backup-temp/linux-android-backup-contact-7.vcf'
Awesome. I found some issues with restoring backups and they'll be fixed later today. Thanks for reporting the bug.
Edit: Fixed everything :)
Exporting contacts (as vCard). adb: error: failed to stat remote object '/storage/emulated/0/linux-android-backup-temp': No such file or directory
I went into the adb shell and that file/folder does not exist.