Error Starting Android Emulators on Ubuntu 18 - android

I'm attempting to start an Android emulator on Jenkins CI, but the startup never completes. On CI the command is running in a Docker image based on ubuntu:18.04. I'm using the following command to start the emulator:
/opt/android-sdk-linux/emulator/emulator -no-audio -no-window -delay-adb \
#Pixel_C_API_25 &
Then I wait for the emulator to complete with:
adb wait-for-device
On my developer machine (macOS 10.14.6), the emulator finishes starting and adb wait-for-device returns, but on CI the emulator never finishes launching. The relevant portions of the log output are here:
Starting emulator
Waiting for emulator
* daemon not running; starting now at tcp:5037
statvfs('/home/ec2-user/.android/avd/Pixel_C_API_25.avd/snapshots/default_boot/ram.img') failed: No such file or directory
### WARNING: could not find /usr/share/zoneinfo/ directory. unable to determine host timezone
emulator: WARNING: encryption is off
Your emulator is out of date, please update by launching Android Studio:
- Start Android Studio
- Select menu "Tools > Android > SDK Manager"
- Click "SDK Tools" tab
- Check "Android Emulator" checkbox
- Click "OK"
* daemon started successfully
### WARNING: could not find /usr/share/zoneinfo/ directory. unable to determine host timezone
Sending interrupt signal to process
Terminated
script returned exit code 143
I think the "emulator is out of date" warning is a red herring, as it doesn't cause problems for me locally. I think the more likely problem is:
statvfs('/home/ec2-user/.android/avd/Pixel_C_API_25.avd/snapshots/default_boot/ram.img') failed: No such file or directory
But I haven't been able to find info on what would cause this problem or fix it. Locally the ram.img file is present.
I've tried with AVDs based on the following system images. Previously there seemed to be an error with x86 not being supported on the x86-related images, but I'm no longer getting that error. Instead, all of them give the above ram.img error:
system-images;android-25;google_apis;arm64-v8a
system-images;android-25;google_apis;armeabi-v7a
system-images;android-28;google_apis;x86_64
system-images;android-28;google_apis;x86
system-images;android-28;default;x86_64
In each case I create the AVD with commands analogous to the following:
sdkmanager --install "system-images;android-25;google_apis;armeabi-v7a"
avdmanager create avd --force --name Pixel_C_API_25 --abi google_apis/armeabi-v7a --package "system-images;android-25;google_apis;armeabi-v7a" --device "pixel_c"
Has anyone successfully gotten an Android emulator to start on Ubuntu 18, and if so, which system image did you use?

Related

Android device emulator fails due to bad permissions Linux

I am trying to install flutter without android-studio, currently the flutter doctor gives all ticks except for android studio and connected devices as per this guide. I created an emulator through avdmanager, and if I run it with flutter emulators --launch pixel it gets stuck on the loading screen and then becomes unresponsive. To get some more information I can run it with ${ANDROID_HOME}/emulator/emulator -avd pixel, this does the same thing but returns the following debug information:
emulator: WARNING: IniFile.cpp:235: Failed to open .ini file /home/cameron/.android/avd/pixel.avd/hardware-qemu.ini for writing.
qemu-system-x86_64: -drive if=none,index=1,id=cache,if=none,file=/home/cameron/.android/avd/pixel.avd/cache.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576: Could not open '/home/cameron/.android/avd/pixel.avd/cache.img.qcow2': Permission denied
Killed
Now since it seems to be a permissions issue, I can run the same command with sudo and it is able to start up the emulator but when I use the virtual power button to start the phone os it crashes with:
host doesn't support requested feature: CPUID.80000001H:ECX.abm [bit 5]
host doesn't support requested feature: CPUID.80000001H:ECX.abm [bit 5]
E0619 23:22:33.309764951 29720 socket_utils_common_posix.cc:201] check for SO_REUSEPORT: {"created":"#1592572953.309674506","description":"SO_REUSEPORT unavailable on compiling system","file":"/mnt/tmpfs/src/android/emu-master-dev/external/grpc/src/core/lib/iomgr/socket_utils_common_posix.cc","file_line":169}
emulator: ERROR: AdbHostServer.cpp:102: Unable to connect to adb daemon on port: 5037
Your emulator is out of date, please update by launching Android Studio:
- Start Android Studio
- Select menu "Tools > Android > SDK Manager"
- Click "SDK Tools" tab
- Check "Android Emulator" checkbox
- Click "OK"
[29707:29707:0619/232311.505803:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
I've tried to common response I found on the internet which is to use adduser on kvm but this didn't change anything. Some windows users have suggested marking certain files as writable but since I don't know which I'm very apprehensive. PS I'm on Ubuntu 18.04. Any help would be very appreciated!
Try
flutter clean
and then restart your flutter

Android emulator not working(black screen and offline) for open source project

I followed instructions here to build an open source android project(aosp-2.3.x).
After I finish building the project with:
. build/envsetup.sh
lunch aosp_arm-eng
make -j16
emulator
I can see a black screen emulator and two warning messages:
Could not automatically detect an ADB binary.
Some emulator functionality will not work until a custom path to ADB
is added in the extended settings page.
Running an x86 based Android Virtual Device (AVD) is 10x faster.
We strongly recommend creating a new AVD.
and in my terminal it shows:
emulator: WARNING: system partition size adjusted to match image file (2050 MB > 200 MB)
emulator: WARNING: encryption is off
when I run adb devices, it shows:
List of devices attached
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
emulator-5554 offline
The emulator works in Anroid Studio, but not from the terminal when I tried to build the open source android project, is there any suggestions on how to fix this issue?
I got the same problem like this, try to uninstall android phone driver (check on remove driver and restart pc) then go on search "universal adb driver", download and setup it, it works for me, hope for you too!
PS C:\Users\Nguyen\AppData\Local\Android\sdk\platform-tools> adb devices
List of devices attached
xxxxxxxxxxxxxxxxxx device

Jenkins running on headless linux aws with xvfb getting error for the connectedAndroidTest espresso

Giving Error on jenkins while running android espresso test.
My server is headless linux aws, and i am using xvfb to run android emulator virtually and want to run test cases.
i have already create emulator with command line
android create avd --force -n nexus4-emulator2 -t "Google Inc.:Google APIs:18" --abi default/armeabi-v7a -s "768x1280" --device "Nexus 4" -c 128M
this is creating emulator, first it was giving permission error, but after adding access permission it get resolved.
now some of logs on jenkins is like below
[android] Starting Android emulator
$ /opt/android-sdk-linux//platform-tools/adb -s emulator-5788
wait-for-device shell getprop init.svc.bootanim [android] Emulator
reported that the startup process is 'running'
[android] Attempting to unlock emulator screen
:Chynge:preBuild UP-TO-DATE
Installing APK 'app-debug.apk' on 'nexus4-emulator(AVD) - 4.3.1' for
Chynge:debug Installed on 1 device.
:app:connectedDebugAndroidTest
com.app_positive.LoginTest > loginTest[nexus4-emulator(AVD) - 4.3.1]
[31mFAILED [0m android.support.test.espresso.NoMatchingViewException:
No views in hierarchy found matching: (with id: com.app:id/btn_login
and with text: is "Login with E-Mail" and is displayed on the screen
to the user)
:app:connectedDebugAndroidTest FAILED
What went wrong: Execution failed for task ':app:connectedDebugAndroidTest'.
There were failing tests. See the report at: file:///data/jenkins/workspace/android-ci-tests/client/android/app/build/reports/androidTests/connected/index.html
[Gradle] - Launching build.
Build step 'Invoke Gradle script' changed build result to FAILURE Xvfb
stopping Finished: FAILURE
![Emulator Configuration][see here]![Gradle task configuration][see here] I haven't added command to create emulator or to open it, but Jenkins provides android emulator plugin that do all things like creating emulator, wait to open, launch emulator, i just have to add configuration for it.
finally i got answer, i tried to create emulator on my windows machine with same configuration on Jenkins,and install app on it , it was showing google play service update pop up, and that's the reason, runner unable to find view on screen, as pop up don't allow to run the app, query of creating emulator is like
path upto android_sdk_tools>> android create avd --force -n emualator_29 -t android-23 --abi google_apis/armeabi-v7a -s "768x1280" --device "Nexus 4" -c 128M
just by taking new version 23, some ideal screen resolution, and one more only armeabi-v7a runs on headless machine...it works for me..thank you..
I haven't used ever Jenkins, but I used Travis CI for building my Github projects. I know that can after installing plugin read Travis configuration files with .yml extensions.
Here's my configuration of Android emulator
- echo no | android create avd --force -n test -t $ANDROID_TARGET --abi armeabi-v7a --sdcard 200M
- emulator -avd test -no-audio -no-window &
- android-wait-for-emulator
- sleep 10
- adb shell settings put global window_animation_scale 0 &
- adb shell settings put global transition_animation_scale 0 &
- adb shell settings put global animator_duration_scale 0 &
- adb shell input keyevent 82 &
From: https://github.com/piotrek1543/LocalWeather/blob/master/.travis.yml
As you can see after creating an emulator instance (first line), I'm executing android-wait-for-emulator as loading the virtual device may take more than few minutes and Espresso test may start before emulator woulb in idle. Also remember to turn off animation and unlock the screen (tha last line).
Try to write similar script.
EDIT: As you're using headless server uncheck this options:
show emulator window
Running on headless build machines
If you have build slaves which are
headless (e.g. Linux servers that don't have a graphical user
interface), you can still run an Android Emulator even although, by
default, the emulator does require a graphical environment.
Just untick the "Show emulator window" configuration option in your
job configuration. This is the equivalent of using the emulator's
"-no-window" command-line option.
From: https://wiki.jenkins-ci.org/display/JENKINS/Android+Emulator+Plugin
use emulator snapshots
Similarly, snapshot support does not fully function for Android 4.0
until SDK Tools r15. An initial snapshot can be created, but
subsequently loading from that snapshot will crash the emulator
immediately. Earlier Android versions are not affected, i.e. you can
still use snapshots with Android 3.2 and earlier. Upgrading to SDK
Tools r15+ should fix this.
As a workaround, you can also uncheck "Use emulator snapshots" in any
jobs where you are seeing problems.
From: https://wiki.jenkins-ci.org/display/JENKINS/Android+Emulator+Plugin
The same solution is described on that screen:
From http://blog.zuehlke.com/en/configure-your-android-project-on-jenkins/
EDIT2: Read this article: https://www.cloudbees.com/blog/continuous-integration-mobile-apps-jenkins-android-builds and notice:
Notice that you can add some additional scripts to your emulator, try to use mine without first line.
Hope it will help

Unable to detect adb version, adb [duplicate]

This question already has answers here:
unable to execute adb in Ubuntu. Downloaded file is meant for x86-64 while I have i686 [duplicate]
(2 answers)
Closed 7 years ago.
I'm using Ubuntu 15.10 32bit on a 32bit machine and the latest version of Android Studio with all packages downloaded from SDK manager (without the Intel atom, TV, Wear).
When I try to run or debug the App (the default simplest hello world) the console show these errors and prompt a pop-up with:
ADB not responding. If you'd like to retry, then please manually kill "adb" and click 'Restart':
Console:
13.31.35 Unable to detect adb version, adb output:
/home/user/Android/Sdk/platform-tools/adb: 1:
/home/user/Android/Sdk/platform-tools/adb: Syntax error: ")"unexpected
13.31.37 Error running app: Unable to obtain debug bridge
I already tried:
killall adb
adb: no such process
and
adb kill-server
adb start-server
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
But the error still occurs.
The problem was that the platform-tools were for a 64bit machine, after replacing those with this version:
https://dl.google.com/android/repository/platform-tools_r23.0.1-linux.zip
Android Studio recognizes the adb.
But after AVD chosen, another error occurs:
Cannot launch AVD in emulator.
Output:
ERROR: 32-bit Linux Android emulator binaries are DEPRECATED, to use them
you will have to do at least one of the following:
- Use the '-force-32bit' option when invoking 'emulator'.
- Set ANDROID_EMULATOR_FORCE_32BIT to 'true' in your environment.
Either one will allow you to use the 32-bit binaries, but please be
aware that these will disappear in a future Android SDK release.
Consider moving to a 64-bit Linux system before that happens.

Eclipse Android SDK ERROR: unknown virtual device name

So, the issue i correctly installed eclipse,android sdk,ndk, coocs2d-x 2.1.4. I can build cocos2d-x android project, import it to eclipse, etc. Everything seems fine, but not really. The problem is that i can't launch my virtual machine to emulate andoid OS. I created avd, it works fine with simple android projects, but when i use it to run cocos2d-x project as android application it does nothing. No output at all. I found this guide and followed it. But i faced a problem. 1st of all, when i follow this step:
Now start the Android for x86 Intel Emulator using the following command:
$ <SDK directory>/tools/emulator-x86 -avd Your_AVD_Name -qemu -m 2047 -enable-kvm
i have an error message:
gloomist-CN tools # ./emulator-x86 #myavd -qemu -m 2047 -enable-kvm
emulator: ERROR: unknown virtual device name: 'myavd'
emulator: could not find virtual device named 'myavd'
But it is in sdk as a valid android virtual device. And the next one. In that tutorial that i pasted link to above, the last step is:
Run the emulator with the correct library path and options
Make sure to
Set the library path to the directory containing the Open GL library for the emulator (LD_LIBRARY_PATH=...)
Run the x86 version of the emulator (run /tools/emulator-x86)
Enable GPU use (Use the option "-gpu on")
Also, you need to specify the name of the Android Virtual Device to use (Use the option "-avd ")
On OS X the command line looks like this
LD_LIBRARY_PATH=~/bin/android-sdk/tools/lib ~/bin/android-sdk/tools/emulator-x86 -verbose -avd android17x86 -gpu on
i don't really know what author meant by all this. Could anyone explain me the way to do it in linux?
So basically, the main problem is: how to run a cocos2d-x project on AVD in eclipse on lixnux? That's it.
I use Linux version 3.2.0-23-generic (buildd#palmer) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu4) ) #36-Ubuntu SMP Tue Apr 10 20:41:14 UTC 2012 (Ubuntu 3.2.0-23.36-generic 3.2.14).
Can anyone help me to figure out how can i accurately launch my cocos2d-x project on AVD using eclipse?
Are you sure 'myavd' is a valid avd?
Try to run this command to get a list of AVD's you have created in your system:
# <SDK directory>/tools/android list avd
And re-run emulator-x86 passing a valid avd.
I also suggest you follow the step by step guide about how to configure your android enviroment which comes with cocos2d-x dist. You can find it in: /samples/Cpp/TestCpp/proj.android/README.md
Hope this helps
I was able to fix this error on Ubuntu 18.04 by running:
sudo chmod 777 /dev/kvm
Its not exactly high security, but it gets the job done.

Categories

Resources