Giter VIP home page Giter VIP logo

android-emulator's Introduction

Android-emulator

ATTENTION: I'm not actively supporting that project, because of a shift in my personal interests. If you want to propose improvement, I can accept it as pull-request.

Thanks to @nightscape for nice optimizations!

Android-emulator is yet another Docker image with Android SDK and emulator inside (based on tons of other works).

My aims:

  • Make stable and reliable Docker container
  • Put some tools for static analysis inside
  • Implement useful commands to Makefile

Docker image avalaible from Docker registry.

Version

0.0.5

Tech

Installation

Use Docker registry with latest tag:

$ docker pull tracer0tong/android-emulator:latest
$ docker run -d -P --name android tracer0tong/android-emulator 

Or use Makefile from repository:

$ git clone https://github.com/tracer0tong/android-emulator.git android-emulator
$ cd android-emulator
$ make run
$ make ports
Use:
adb kill-server
adb connect 172.17.0.2:32769
or
adb connect 0.0.0.0:32769
$ adb kill-server
$ adb connect 0.0.0.0:32769
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
connected to 0.0.0.0:32769
$ adb devices
List of devices attached
0.0.0.0:32769   device

$ adb shell
root@generic_x86:/ #

By default it will create and run API 19 (arm) for you, but some other versions also supported. You can run emulator for API versions: 19, 21, 22 x86/armeabi-v7a (as -a option). This is the most popular API versions among usable devices.

$ make EMULATOR="android-22" ARCH="x86" run

or

$ docker run -e "EMULATOR=android-22" -e "ARCH=x86" -d -P --name android tracer0tong/android-emulator

How to connect to emulator

Emulator container exposed 4 port's by default: tcp/22 - SSH connection to container (login: root, password: android, change this if you are security concerned)

  • tcp/5037 - ADB
  • tcp/5554 - ADB
  • tcp/5555 - ADB connection port
  • tcp/5900 - QEMU VNC connection (doesn't support pointing device and keyboard, I recommend to use MonkeyRunner for pointing simulation or 3rd-party VNC server pushed into emulator)

Q: How to understand, which ip address use to connect?

A: Depend on Docker toolset: for GUI tools as Kitematic just check port forwardind settings on container home page. If you are using Docker under Linux environment, just use docker ps command.

$ sudo docker ps
CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS              PORTS                                                                                                                       NAMES
0dd15cd1bd43        tracer0tong/android-emulator   "/entrypoint.sh -e an"   6 days ago          Up 6 days           0.0.0.0:32812->22/tcp, 0.0.0.0:32811->5037/tcp, 0.0.0.0:32810->5554/tcp, 0.0.0.0:32809->5555/tcp, 0.0.0.0:32808->5900/tcp   android
$ ssh [email protected] -p 32812
[email protected]'s password:
Welcome to Ubuntu 12.04.5 LTS (GNU/Linux 3.19.0-28-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

root@0dd15cd1bd43:~#

Makefile

Additional Makefile targets:

$ make kill
$ make ps
$ make ports
$ make clean

Todo's

  • Add new targets to Makefile (create new AVD, update sdk etc.)
  • Optimize Dockerfile
  • Provide options for emulator, port redirection, etc.
  • Add androguard, drozer etc. to image

License

Apache

android-emulator's People

Contributors

nightscape avatar tracer0tong avatar truongsinh avatar wseng avatar yijunyu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-emulator's Issues

question in connect to vnc

when I try to connect android with VNC in port tcp/5900, I just connect to the mac itself, not the android in docker, why?

how to use tracer0tong/android-emulator

I got your docker image of android emulator: tracer0tong/android-emulator from github. I use it this way:

  1.         $ docker pull tracer0tong/android-emulator:latest
    
  2.         $ docker run -d -P --name android tracer0tong/android-emulator 
    
  3.         $ docker ps –a 
    

I get:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a5f9318c6496 tracer0tong/android-emulator "/entrypoint.sh -e an" 25 minutes ago Up 25 minutes 0.0.0.0:32771->22/tcp, 0.0.0.0:32770->5554/tcp, 0.0.0.0:32769->5555/tcp, 0.0.0.0:32768->5900/tcp android
So, it seems working and it can provide adb ports.
4) $ adb connect 192.168.99.100:32769, it succeed
5) $ adb devices. It failed, does not display any information

I tried to play with this image for 2 days, used different ways , but can’t make it work.
I hope to get an android emulator that can support adb commands, so I can install software in it. And by using Appium, I can control this android emulator, just like I control android physical devices.

Remove SSH server

What is the added value of having the SSH server running inside the docker image?
The image can be easily accessed by calling
docker exec -it ${DOCKER_IMAGE_ID} bash
or
docker run -it ${DOCKER_IMAGE_ID} /bin/bash

Cannot `adb connect` from windows host

I'm having issues connecting to the devices from a windows host when the docker machine is running. Using the new linux subsystem in windows (ubuntu flavored) I can ssh in fine and poke around. I just don't know why it's complaining. The adb tools are on the windows host. Just for kicks and giggles though I tried to use the same tools through the linux subsystem and got similar results. I'm at a loss.

the running container

> docker ps
5972aa2fe34        tracer0tong/android-emulator   "/entrypoint.sh"    31 minutes ago      Up 31 minutes
       0.0.0.0:32774->22/tcp, 0.0.0.0:32773->80/tcp, 0.0.0.0:32772->443/tcp, 0.0.0.0:32771->5037/tcp, 
0.0.0.0:32770->5554/tcp, 0.0.0.0:32769->5555/tcp, 0.0.0.0:32768->5900/tcp   android

adb connect using 0.0.0.0

> adb kill-server
> adb connect 0.0.0.0:32769
* daemon not running; starting now at tcp:5037
* daemon started successfully
unable to connect to 0.0.0.0:32769: cannot connect to 0.0.0.0:32769: The requested address is not 
valid in its context. (10049)

adb connect using IpAddress

> docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' android
172.17.0.2
> adb kill-server
> adb connect 172.17.0.2:32769
* daemon not running; starting now at tcp:5037
* daemon started successfully
unable to connect to 172.17.0.2:32769: cannot connect to 172.17.0.2:32769: A connection attempt 
failed because the connected party did not properly respond after a period of time, or established 
connection failed because connected host has failed to respond. (10060)

A trimmed netstat -a

 Proto  Local Address          Foreign Address        State
  TCP    0.0.0.0:80             IVYSAUR:0              LISTENING
  TCP    0.0.0.0:135            IVYSAUR:0              LISTENING
  TCP    0.0.0.0:445            IVYSAUR:0              LISTENING
  TCP    0.0.0.0:1536           IVYSAUR:0              LISTENING
  TCP    0.0.0.0:1537           IVYSAUR:0              LISTENING
  TCP    0.0.0.0:1538           IVYSAUR:0              LISTENING
  TCP    0.0.0.0:1539           IVYSAUR:0              LISTENING
  TCP    0.0.0.0:1540           IVYSAUR:0              LISTENING
  TCP    0.0.0.0:1544           IVYSAUR:0              LISTENING
  TCP    0.0.0.0:1546           IVYSAUR:0              LISTENING
  TCP    0.0.0.0:1641           IVYSAUR:0              LISTENING
  TCP    0.0.0.0:2179           IVYSAUR:0              LISTENING
  TCP    0.0.0.0:8080           IVYSAUR:0              LISTENING
  TCP    0.0.0.0:32768          IVYSAUR:0              LISTENING
  TCP    0.0.0.0:32769          IVYSAUR:0              LISTENING
  TCP    0.0.0.0:32770          IVYSAUR:0              LISTENING
  TCP    0.0.0.0:32771          IVYSAUR:0              LISTENING
  TCP    0.0.0.0:32772          IVYSAUR:0              LISTENING
  TCP    0.0.0.0:32773          IVYSAUR:0              LISTENING
  TCP    0.0.0.0:32774          IVYSAUR:0              LISTENING
  TCP    0.0.0.0:46708          IVYSAUR:0              LISTENING
  TCP    0.0.0.0:57621          IVYSAUR:0              LISTENING
.
.
.
  TCP    127.0.0.1:22223        IVYSAUR:0              LISTENING
  TCP    127.0.0.1:32774        IVYSAUR:57088          ESTABLISHED  ### My SSH session
  TCP    127.0.0.1:44430        IVYSAUR:0              LISTENING
.
.
.

I've been banging my head against the wall for quite some time now and any help towards getting adb to connect would be appreciated.

SSH permission denied, VNC denied

Running Docker on Windows 10, started with

$ docker run -d -P --name android tracer0tong/android-emulator

docker ps shows the container and available ports just fine.

$ docker ps
CONTAINER ID        IMAGE                          COMMAND             CREATED             STATUS              PORTS                                                                                                                       NAMES
a494f19f07a4        tracer0tong/android-emulator   "/entrypoint.sh"    32 minutes ago      Up 32 minutes       0.0.0.0:32772->22/tcp, 0.0.0.0:32771->5037/tcp, 0.0.0.0:32770->5554/tcp, 0.0.0.0:32769->5555/tcp, 0.0.0.0:32768->5900/tcp   android

When I try SSHing into it using user root it gives me "connection refused".

$ ssh [email protected] -p 32722
ssh: connect to host 0.0.0.0 port 32722: Connection refused

Trying to connect via VNC (using RealVNC client and port 5900) it gives me "denied by remote host".

mounting volumes

I was not able to mount any volumes into the image by specifying -v... option. Did I miss something or is this simply undoable the way I thought it should work out?

can I upgrade the android SDK to 24.2

Hey, I am using your Dockerfile to build the image on my local machine with 24.2 android SDK version. When I try to run a container with that image, it raise KVM is not installed on this machine (/dev/kvm is missing), but when I change android SDK version back to 23, it works well. Any thing I missing? Why I can not upgrade the SDK here? :)

Multiple emulator in same docker container

Hi Author,

it is possible to create several avd in the docker container manually and start them?
I tried the command in the entrypoint.sh, but failed.
echo "no" | /usr/local/android-sdk/tools/android create avd -f -n test2 -t ${EMULATOR} --abi default/${ARCH}
echo "no" | /usr/local/android-sdk/tools/emulator64-${EMU} -avd test2 -noaudio -no-window -gpu off -verbose -qemu -usbdevice tablet -vnc :0

Emulator hangs on black screen

When i trying to boot up the devices using CPU/ABI armeabi-v7a, 4GB RAM, 3GB Storage.
Its just hang on black screen,and nothing appear anymore,just blank
Preview:
https://media.discordapp.net/attachments/840846574925512735/842351704926453790/Screenshot_2021-05-13_184438.png
I tried to hold & presss the power button,nothing changed.Still BLANK.

I dont know why is this happening,please help!
(Its work before,but now it doesnt work.This is a new devices but with all same stuff)

arm64-v8a image support

Google has system-images;android-24;default;arm64-v8a image that would be nice to utilize for testing 64bit arm native code in a CI situation.

I took a shot at it, but can't expose the emulator to other machines.

Things to note:

the android wrapper is deprecated (sdkmanager and it's new package name scheme can replace it's use in Dockerfile, and avdmanager can replace it's use in entrypoint.sh) The android tool doesn't like android-24,sys-img-arm64-v8a-android-24 (maybe new issue)

emulator64-arm moved (it's in $ANDROID_HOME/emulator now). There is a binary "emulator" that will start the image, but it hooks up the crash monitor and starts a local adb and I haven't found the magic to expose it to other machines (running Docker for Mac, current arm32 images work fine) or start it bare (the old emulator wrapper script seems to be a binary now that does some stuff I haven't dug into.)

QUESTION: add apk and files to the image

I'm quite new to Docker and was wondering if it's possible to already install apks and add files to the emulator, and make a new image out of it, to avoid having to copy and reinstall things each time the container is started?

I tried doing a commit after adding apks and file, but when running the resulting image, no apk was installed and no file was there.

Specify explicit version of the base image

Currently the Dockerfile is based on latest ubuntu image
FROM ubuntu
and therefore may become unstable at some point in time.
Please consider changing to specific verified version of ubuntu ex. ubuntu:16.04.

cannot download java-7-oracle ,404

hi, the java you use PPA -> java7 cannot download now , maybe you can update to java-8-oracle.

by the way, can you tell me what's the point that can use adb connect in Docker , I try like what you did, but it just can't connect . Is the "-usbdevice tablet" or "socat" or other, please tell me ,thank you.

device offline

Hi,

I just follow your introduction to install the emulator. But it shows device is offline after connected the emulator. Do you have meet this issue before ?
I've tried some ways to fix it, such as restart adb( adb kill-server & start-server) , delete .android/adbkey & adbkey.pub. But none work...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.