First I have installed novnc and sdk in linux, each of them runs correctly, however, I don't know how to connect emulator with novnc. The following commands are used in my experience.
android list targets
android create avd -n myAVD -t 1
emulator -avd myAVD -qemu -vnc 2
vncserver
vncserver -geometry 1024x768 :1
./utils/launch.sh --vnc 127.0.0.1:5901
Related
I created the avd by doing the following:
./avdmanager create avd -c 100M -n test -d 9 -k 'system-images;android-26;google_apis_playstore;x86'
I get the following output after running avdmanager list avd
Name: test
Device: Nexus 5X (Google)
Path: /home/me/.android/avd/test.avd
Target: Google Play (Google Inc.)
Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis_playstore/x86
Sdcard: 100M
Then I booted up the emulator by running
emulator -avd test -no-audio -no-boot-anim -no-window -skip-adb-auth & adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; input keyevent 82'
Then finally I try to run the tests with
./gradlew connectedDebugAndroidTest
However, the process hangs and I assume will do so indefinitely, but I will kill the process after 10 minutes. I am not even sure how to debug this let one resolve it so any help would be greatly appreciated!
Which process hangs? The test process? In that case you should know which gradle task hangs at least.
However, if it is the emulator process hanging (not finishing booting) then I was able to resolve that in headless environment with these extra params for kvm:
-qemu -enable-kvm -snapshot
Obviously, you need kvm set up and enabled. (KVM installation for ubuntu)
Trying to setup kvm on ubuntu here.
The official docs only points to ubuntu docs to install kvm
The steps provided here and here
Says to In Android Studio
Go to Run > Edit Configurations.
To set as global default for all projects, select "Android
Application" under "Defaults".
Go to the emulator tab, check "Additional command line options"
Add -qemu -m 2047 -enable-kvm
The tab is not present in 2.3.3 and has been a know issue since 1.5
But the issue has been reported and closed as intended behavior with no valid answer to on where to run
-qemu -m 2047 -enable-kvm
Update 1
KVM is supported
nishon#nishon-Inspiron-5420 ~ $ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
nishon#nishon-Inspiron-5420 ~ $ egrep -c '(vmx|svm)' /proc/cpuinfo
4
Passing the additional while launching avd from bash shell seems to be
working. I am entirely not sure though.
nishon#nishon-Inspiron-5420 ~ $ emulator -avd [Enter AVD name] -qemu -m 2047 -enable-kvm
Before tying this command you need to setup path to ADB in your .bashrc(Ubuntu) or path(Windows)
Reference https://developer.android.com/studio/run/emulator-commandline.html
I too need that additional command line option for emulator
but anyhow i found a alternative way for it...
go to the sdk/tools
cd ~/Android/Sdk/tools
run this command to start avd using system libraries..
./emulator -avd YOUR_AVD_NAME -use-system-libs
the apps worked fine for me when the emulator is running in the background.
I came across weird problem that I dont fully understand. I try to start more than 2 AVD from terminal. It works even for 4 AVDs but only on special conditions.
There is a code I use for 3 AVDs:
echo "no" | $ANDROID_HOME/tools/android create avd --name "Test-Emulator-API23-Nexus-5" --target "Google Inc.:Google APIs:23" --abi google_apis/x86_64 --device "Nexus 5" --skin "1080x1920"
echo "no" | $ANDROID_HOME/tools/android create avd --name "Test-Emulator-API23-Nexus-7" --target "Google Inc.:Google APIs:23" --abi google_apis/x86_64 --device "Nexus 7" --skin "1200x1920"
echo "no" | $ANDROID_HOME/tools/android create avd --name "Test-Emulator-API23-Nexus-10" --target "Google Inc.:Google APIs:23" --abi google_apis/x86_64 --device "Nexus 10" --skin "2560x1600"
$ANDROID_HOME/platform-tools/adb kill-server
$ANDROID_HOME/platform-tools/adb start-server
$ANDROID_HOME/tools/emulator -port 5556 -avd Test-Emulator-API23-Nexus-5 -gpu on &>/dev/null &
$ANDROID_HOME/tools/emulator -port 5558 -avd Test-Emulator-API23-Nexus-7 -gpu on &>/dev/null &
$ANDROID_HOME/tools/emulator -port 5560 -avd Test-Emulator-API23-Nexus-10 -gpu on &>/dev/null &
It works when I copy paste last 3 lanes which launches AVD to terminal AT ONCE. Then all 3 AVDs start at the same time and successfully launch. It also works for 4 AVDs.
It won't allow me to launch more than 2 AVDs if I try to do it sequentially. So I put 1st launch lane for Nexus-5. I wait until it boots completely. Then I put 2nd launch lane for Nexus-7 - it also boots successfully. And then if I try to launch more AVD I get freeze - black screen freeze on startup.
Any idea why this happens? Why can I launch many AVDs at the same time, but I can't start them one by one?
Problem is related to memory allowance set to HAXM. My HAXM RAM usage by default was 2gb. After reinstalling HAXM
https://software.intel.com/en-us/android/articles/intel-hardware-accelerated-execution-manager
and assigning 6gb of memory to it, I am able to start 4 AVDs in sequence.
My guess why it worked before was: because all AVDs were started at once - in the same moment, all of them passed memory limit check and because of that they were allowed to run.
I set up a Jenkins Job on Cloudbees and I can successfully checkout and compile my Android project there. Now I would like to run some JUnit tests in the android emulator and added the Android emulator plugin. I set the “Show Emulator Window“ option to false but after startup of the emulator I always get the error message: “Emulator did not appear to start; giving up”.
Has anyone experience with Android builds on Cloudbees?
Build log:
$ /opt/android/android-sdk-linux/tools/android list target
[android] Using Android SDK: /opt/android/android-sdk-linux
[android] Creating Android AVD: /home/jenkins/.android/avd/hudson_en-US_160_WVGA_android-17_armeabi-v7a.avd
[android] /opt/android/android-sdk-linux/tools/android create avd -f -a -c 64M -s WVGA800 -n hudson_en-US_160_WVGA_android-17_armeabi-v7a -t android-17 --abi armeabi-v7a
$ /opt/android/android-sdk-linux/platform-tools/adb start-server
[android] Starting Android emulator
$ /opt/android/android-sdk-linux/tools/emulator -no-boot-anim -ports 59102,56142 -prop persist.sys.language=en -prop persist.sys.country=US -avd hudson_en-US_160_WVGA_android-17_armeabi-v7a -no-snapshot-load -no-snapshot-save -no-window
Failed to Initialize backend EGL display
* daemon not running. starting it now on port 52538 *
* daemon started successfully *
[android] Emulator did not appear to start; giving up
$ /opt/android/android-sdk-linux/platform-tools/adb disconnect localhost:56142
[android] Stopping Android emulator
$ /opt/android/android-sdk-linux/platform-tools/adb kill-server
Compare your job configuration with https://partnerdemo.ci.cloudbees.com/job/Android-dev/job/stockfish-android-cloud/, paying particular attention to the following settings:
Inject env var: LD_LIBRARY_PATH=/opt/android/android-sdk-linux/tool/lib
Target ABI: armeabi-v7a
Advanced -> Emulator Options: -no-audio -gpu off
Advanced -> Emulator Executable: emulator64-arm
I created my android virtual device using command as folow:
android create avd --target 1 --name emu --abi x86
then I tried to run emulator:
emulator -avd emu &
during the emulator starting I was trying to make command as follow:
adb shell
but I had an error:
error: device offline
and when i made command:
echo $?
I had output "1" until emulator get started.
Is it any possibility to check current emulator state using the terminal command?
You can use another terminal window and type adb logcat commnad.