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

Skip created a corrupted emulator in ADB #120

Open
virtual-meme-machine opened this issue May 16, 2024 · 2 comments
Open

Skip created a corrupted emulator in ADB #120

virtual-meme-machine opened this issue May 16, 2024 · 2 comments

Comments

@virtual-meme-machine
Copy link

Problem

I just set up Skip on my laptop and forgot to open the Android emulator before building the hello-skip test app in Xcode. This obviously failed but somehow added an emulator that doesn't exist which shows up as offline when I run adb devices:

> adb devices
List of devices attached
emulator-5562	offline

I have verified that the Android emulator does not exist and qemu is not running. This entry does not show up when I run the same command on the adb exec located at ~/Library/Android/sdk/platform-tools/adb nor does it show up when I run ~/Library/Android/sdk/emulator/emulator -list-avds.

Attempted Resolution

I have tried to resolve this by:

  • Deleting and reinstalling Android Studio
  • Deleting and reinstalling Homebrew
  • Deleting and reinstalling Skip
  • Deleting ~/.android and ~/Library/Android and letting Android Studio recreate them during initial setup
  • Trying all of the answers listed in https://stackoverflow.com/questions/39247033

I also tried to dig through the Skip code to find how this is happening but I was unable to find anything that stood out. This could also be a bug in ADB that Skip is unknowingly triggering.

Additional Thoughts

Is there a reason why Skip doesn't just boot the emulator directly instead of requiring the user to manually start it? This could be accomplished very easily by doing something like:

> ~/Library/Android/sdk/emulator/emulator -list-avds
Pixel_8_API_34

> ~/Library/Android/sdk/emulator/emulator @Pixel_8_API_34

This is preventing me from using Skip entirely and has also broken adb for other use cases which do not handle multiple devices well.

@marcprux
Copy link
Contributor

Skip doesn't ever create or launch an emulator. As you point out, this would be a nice feature that we would like to add in the future, but currently we require it to have already been started, either by launching it from Android Studio or via the command line.

I've never seen the issue you describe, nor have I seen an "offline" emulator before, but I suppose it is possible that something could have been created as an accidental side-effect of the launch script that is run as part of the build phases for the app target from Xcode. In any case, one solution that I didn't see mentioned in the Stack Overflow article would be to open the Device Manager from Android Studio's "Tools" menu, and then see if the zombie emulator is listed there. If it is, you should be given an option to delete it.

Screenshot 2024-05-16 at 15 17 33

Please let us know if this helps – if not, we'll help you figure it out. In any case, we're interested in the solution to the problem so we can document it.

Also, in the interim, if you are having issues with the zombie emulator preventing you from using other tools that assume a single (functional) emulator running, you can usually specify the emulator to use by setting the ANDROID_SERIAL environment variable to the emulator you want to use. You can do this with Skip as well: if you edit the "run skip gradle" build phase for the app target, you can add a line like "ANDROID_SERIAL=emulator-5554" to the beginning of the script to force it to use a specific emulator (or device).

Screenshot 2024-05-16 at 15 19 05

@virtual-meme-machine
Copy link
Author

I suppose it is possible that something could have been created as an accidental side-effect of the launch script that is run as part of the build phases for the app target from Xcode.

I was able to confirm its something Skip is doing, the adb exec located at ~/Library/Android/sdk/platform-tools/adb was not showing the offline device but after symlinking it to /opt/homebrew/bin/adb and running the Xcode build process again it is now showing it.

Oddly enough I happened to run adb devices while I had skip checkup running in another terminal window and the offline device was not listed. I thought maybe it had fixed itself but I ran it again after the checkup finished and it was back. Testing again by spamming adb devices every few seconds while skip checkup runs reproduced the same effect, the phantom device disappears for a bit around the Build hello-skip and Test Swift stages of the checkup and then comes back by the time it gets to the Test Kotlin stage.

In any case, one solution that I didn't see mentioned in the Stack Overflow article would be to open the Device Manager from Android Studio's "Tools" menu, and then see if the zombie emulator is listed there. If it is, you should be given an option to delete it.

Yep I already tried that, sorry I should have been specific about that earlier.

Please let us know if this helps – if not, we'll help you figure it out. In any case, we're interested in the solution to the problem so we can document it.

I appreciate the support, let me know what I can do to help diagnose this. I am happy to provide logs or something if needed.

you can add a line like "ANDROID_SERIAL=emulator-5554" to the beginning of the script to force it to use a specific emulator (or device).

I had to export that environment variable in the run skip gradle script to get it to work but that does unblock me for now, thank you!

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

2 participants