snapcrafters / android-studio

A community-maintained package to easily install Android Studio on Linux
https://developer.android.com/studio/index.html
47 stars 16 forks source link

[Solved]: Virtual Android Device causes PC to freeze. #105

Closed dirkmittler closed 1 year ago

dirkmittler commented 1 year ago

What happened?

I'm trying to use the Snap.

Created a sample project from template, compiled it successfully, and then proceeded to try to get it to run in a virtual device image.

I have set up KVM on the system side.

Next, I proceed to define a virtual device with a system image: Pixel 6, Android 10 or Android 12. This downloads and installs.

However, when I try to run the app in the virtual device, there is a long pause while the status message displays: Connecting to remaining devices. As if the IDE could not communicate with the device in the BG. And then, my whole PC just freezes.

There are no error messages.

I'm running Debian 11, 64-bit.

Sincerely, Dirk

What should have happened?

At some point, the emulated device should have become active, to the point of allowing the IDE to communicate with it.

Output of snap info $snap_name

name:      android-studio
summary:   The IDE for Android
publisher: Snapcrafters
store-url: https://snapcraft.io/android-studio
contact:   https://github.com/snapcrafters/android-studio/issues
license:   unset
description: |
  Android Studio provides the fastest tools for building apps on every type
  of Android device.

  World-class code editing, debugging, performance tooling, a flexible build
  system, and an instant build/deploy system all allow you to focus on
  building unique and high quality apps.

  This snap is maintained by the Snapcrafters community, and is not necessarily endorsed or
  officially maintained by the upstream developers.
commands:
  - android-studio
snap-id:      VNTeIi51l6cIZ1gaWHwx0PoP7JaCb61c
tracking:     latest/stable
refresh-date: yesterday at 21:32 EDT
channels:
  latest/stable:    2021.3.1.17 2022-11-10 (125) 1GB classic
  latest/candidate: ↑                                
  latest/beta:      2021.2.1.15 2022-07-02 (123) 1GB classic
  latest/edge:      2022.2.1.19 2023-05-19 (126) 1GB classic
installed:          2021.3.1.17            (125) 1GB classic

Output of snap connections $snap_name

(No output. Running with --classic confinement.)

Output of snap version

snap    2.59.2
snapd   2.59.2
series  16
debian  11
kernel  5.10.0-23-amd64

Relevant log output

Cannot obtain log, must hold power button for 10 seconds to shut down computer.

Teminal output of app

(None.)
dirkmittler commented 1 year ago

So, I've gotten the IDE to work with a different virtual device.

This time, I chose a Pixel 2, with API Level 23, which corresponds to Android 6. And, I selected that the graphics should be software graphics, instead of hardware graphics. And I think it was this last settings change, that actually allowed the demo app to run.

The PC which I'm doing this on is using an NVIDIA graphics card, with the Nouveau drivers. There have been numerous issues in the past, just because these non-proprietary drivers are not strong enough.

dirk@Xenon:~$ inxi -G
Graphics:  Device-1: NVIDIA GF104 [GeForce GTX 460] driver: nouveau v: kernel 
           Display: x11 server: X.Org 1.20.11 driver: loaded: modesetting unloaded: fbdev,vesa resolution: 1920x1080~60Hz 
           OpenGL: renderer: NVC4 v: 4.3 Mesa 20.3.5 
dirk@Xenon:~$

Further, it can make sense that if the Emulator is being implemented via KVM, and told to connect directly to graphics hardware, there can be no end of issues to resolve, which this thread doesn't go deep enough to cover.

I am considering this issue Solved, which it will remain, unless for some reason I find in the near future, that I need to write an Android app using hardware graphics.

Dirk