Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No SDCard or writable storage apparently available on running AVD. Unable to write even from adb. #102

Closed
growse opened this issue Oct 28, 2020 · 4 comments

Comments

@growse
Copy link

growse commented Oct 28, 2020

I've got an issue that seems similar to #56 but with some extra complication. I'm trying to kick off a screenrecord via adb before I run a gradle task, and then kill it once the task is done. My workflow is:

jobs:
  test:
    name: Build & Test
    runs-on: macos-latest
    steps:
   ... checkout etc ...
    - name: Test with Gradle on the emulator api=30
      uses: reactivecircus/android-emulator-runner@v2
      with:
        api-level: 30
        working-directory: project
        script: |
            adb emu geo fix 0 51
            adb shell screenrecord /storage/emulated/0/capture.mpg &
            ./gradlew createDebugCoverageReport
            adb shell pkill -INT screenrecord
            cd app/build/reports/ && adb pull /storage/emulated/0/capture.mpg
        profile: pixel_3a
        target: google_apis

However, I get an error here: Unable to open '/storage/emulated/0/capture.mpg': No such file or directory. Putting some adb commands in the scrip to find out what the filesystem of the device looks like, I see:

bin/sh -c \adb shell ls -laht /
total 32K
drwxrwx--x  47 system system    4.0K 2020-10-28 15:21 data
drwxr-xr-x  21 root   root      1.3K 2020-10-28 15:19 dev
drwxr-xr-x  46 root   root       920 2020-10-28 15:19 apex
drwxr-xr-x  15 root   system     320 2020-10-28 15:19 mnt
drwx--x---   4 shell  everybody   80 2020-10-28 15:19 storage
dr-xr-xr-x  41 root   root         0 2020-10-28 15:19 acct
dr-xr-xr-x  13 root   root         0 2020-10-28 15:19 sys
drwxr-xr-x   3 root   root         0 2020-10-28 15:19 config
dr-xr-xr-x 245 root   root         0 2020-10-28 15:19 proc
drwx------   2 root   root       16K 2020-10-13 22:35 lost+found
drwxr-xr-x  23 root   root      4.0K 2020-10-13 22:35 .
drwxr-xr-x  23 root   root      4.0K 2020-10-13 22:35 ..
lrw-r--r--   1 root   root        11 2020-10-13 22:35 bin -> /system/bin
lrw-r--r--   1 root   root        50 2020-10-13 22:35 bugreports -> /data/user_de/0/com.android.shell/files/bugreports
lrw-r--r--   1 root   root        17 2020-10-13 22:35 d -> /sys/kernel/debug
lrw-------   1 root   root        23 2020-10-13 22:35 default.prop -> system/etc/prop.default
lrw-r--r--   1 root   root        11 2020-10-13 22:35 etc -> /system/etc
lrw-r--r--   1 root   root        21 2020-10-13 22:35 sdcard -> /storage/self/primary
drwxr-xr-x  12 root   root      4.0K 2020-10-13 22:35 system
drwxr-xr-x  10 root   root      4.0K 2020-10-13 22:34 product
drwxr-xr-x   9 root   root      4.0K 2020-10-13 22:34 system_ext
drwxr-xr-x   8 root   root      4.0K 2020-10-13 22:24 vendor
drwxr-xr-x   2 root   root      4.0K 2020-10-13 21:59 debug_ramdisk
drwxr-xr-x   2 root   root      4.0K 2020-10-13 21:59 odm
drwxr-xr-x   2 root   root      4.0K 2020-10-13 21:59 oem
drwxr-xr-x   3 root   root      4.0K 2020-10-13 21:59 res
-?????????   ? ?      ?            ?                ? adb_keys
l?????????   ? ?      ?            ?                ? cache -> ?
d?????????   ? ?      ?            ?                ? data_mirror
l?????????   ? ?      ?            ?                ? init -> ?
-?????????   ? ?      ?            ?                ? init.environ.rc
d?????????   ? ?      ?            ?                ? linkerconfig
d?????????   ? ?      ?            ?                ? metadata
/bin/sh -c \adb shell ls -laht /storage
total 2.0K
drwx--x---  4 shell everybody   80 2020-10-28 15:19 .
drwxr-xr-x  3 root  root        60 2020-10-28 15:19 emulated
drwxr-xr-x  2 root  root        40 2020-10-28 15:19 self
drwxr-xr-x 23 root  root      4.0K 2020-10-13 22:35 ..
/bin/sh -c \adb shell ls -laht /storage/self
total 0
drwxr-xr-x 2 root  root      40 2020-10-28 15:19 .
drwx--x--- 4 shell everybody 80 2020-10-28 15:19 ..
/bin/sh -c \adb shell ls -laht /storage/emulated/
total 0
drwxr-xr-x 3 root  root      60 2020-10-28 15:08 .
drwx--x--- 4 shell everybody 80 2020-10-28 15:08 ..
drwxr-xr-x 2 root  root      40 2020-10-28 15:08 0
/bin/sh -c \adb shell ls -laht /storage/emulated/0/
total 0
drwxr-xr-x 2 root root 40 2020-10-28 15:08 .
drwxr-xr-x 3 root root 60 2020-10-28 15:08 ..

So /sdcard points at /storage/self/primary which doesn't exist. /storage/emulated/0 exists but is empty, and adb itself can't write to it.

This contrasts with a device created locally with the same avdmanager commands (avdmanager create avd --force -n test --abi google_apis/x86 --package system-images;android-30;google_apis;x86 --device pixel_3a and emulator -avd test -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim). In this case /storage/self/primary exists, is a symlink to /storage/emulated/0 and contains what you'd expect:

adb shell ls -lah /storage/emulated/0
total 2.3M
drwx------ 2 u0_a150  u0_a150  4.0K 2020-10-27 19:24 Alarms
drwxrws--x 5 media_rw media_rw 4.0K 2020-10-27 19:24 Android
drwx------ 2 u0_a150  u0_a150  4.0K 2020-10-27 19:24 Audiobooks
drwx------ 2 u0_a150  u0_a150  4.0K 2020-10-27 19:24 DCIM
drwx------ 2 u0_a150  u0_a150  4.0K 2020-10-27 19:24 Documents
drwx------ 2 u0_a150  u0_a150  4.0K 2020-10-27 19:24 Download
drwx------ 3 u0_a150  u0_a150  4.0K 2020-10-27 19:24 Movies
drwx------ 3 u0_a150  u0_a150  4.0K 2020-10-27 19:24 Music
drwx------ 2 u0_a150  u0_a150  4.0K 2020-10-27 19:24 Notifications
drwx------ 4 u0_a150  u0_a150  4.0K 2020-10-27 22:43 Pictures
drwx------ 2 u0_a150  u0_a150  4.0K 2020-10-27 19:24 Podcasts
drwx------ 2 u0_a150  u0_a150  4.0K 2020-10-27 19:24 Ringtones
@ychescale9
Copy link
Member

ychescale9 commented Oct 30, 2020

Thanks for the thorough investigation!

I was able to reproduce the issue on API 30 but was able to get it to work on API 23.

So I went on to test all API levels from 23 to 30 (default/x86) and got this.

Could you test with API 26-29 with target: default and see if it works for you?

I also found out that with API 29 default works but google_apis doesn't, and API 30 system image with default target isn't available yet.

I'll try to take another look at this next week.

@growse
Copy link
Author

growse commented Nov 2, 2020

Annoyingly, I need the google_apis image to test with for the moment. It's also weird that it seems to work ok with avds created locally.

@vinaysshenoy
Copy link
Contributor

vinaysshenoy commented Nov 9, 2021

Adding this here in case someone runs into the same issue.

We ran into the same problem for our instrumented tests where we needed to pull some data off external storage after tests complete, but the directory was unreadable on API 30+ devices.

Turns out, the solution was that we needed to restart ADB as root before running our tests. See our workflow for a sample of what we did.

This could be something that is made a part of the GitHub action runner itself for devices API 30+ instead of us needing to do it in our tests.

ouchadam added a commit to element-hq/element-android that referenced this issue Nov 9, 2021
ouchadam added a commit to element-hq/element-android that referenced this issue Nov 10, 2021
@mrk-han
Copy link
Collaborator

mrk-han commented Nov 2, 2022

Closing per workaround here -> #102 (comment)

@mrk-han mrk-han closed this as completed Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants