Git Product home page Git Product logo

android-emulator-m1-preview's Introduction

Android Emulator M1 Preview

Note: There is an official repo now which is preferred: (https://github.com/google/android-emulator-m1-preview). We will still watch this repo for issues and comments, but please redirect your activity to the official repo.

This is a preview of some basic Android emulation functionality on the M1. There are still many issues, but apps work at a basic level. To be updated soon with more fixes. The release tag corresponds to this commit: https://android.googlesource.com/platform/external/qemu/+/aca144a9e9264b11c2d729096af90d695d01455d

Known issues

  • Webview doesn't work
  • No device skins
  • Video codecs not working
  • 32 bit ARM apps won't work
  • Graphical glitches in some Vulkan apps
  • Popup on startup about not being able to find the ADB path (ADB will still notice the emulator if you have it installed though)
  • When building, it may be faster to start then cancel the Python triggered build and then reissue ninja -C objs install/strip versus letting the Python triggered build finish.

How to use

This only works on M1 Apple Silicon Macs. M1 (or equivalently capable) SoCs are required; note that this does not work on DTKs as they do not support ARM64 on ARM64 hardwre virtualization via Hypevisor.framework.

Go to the Github releases page, download a .dmg, drag to the Applications folder, and run. You'll first need to right click the app icon and select Open and then skip past the developer identity verification step (we are working on providing official identity info). The first few times it starts up it will take a while to show up, but subsequent launches will be faster.

If you've installed Android Studio and Android SDK and adb is available, the emulator should be visible from Studio and work (deploy built apps, debug apps, etc).

How to configure

Edit /Applications/Android\ Emulator.app/Contents/MacOS/aosp-master-arm64-v8a/config.ini. Some notable options:

  • disk.dataPartition.size: size of userdata. When reconfiguring, you'll also need to delete all userdata*.img files in that directory.
  • fastboot.forceColdBoot,fastboot.forceFastBoot: whether to enable snapshots. Current default is snapshots disabled. Set fastboot.forceColdBoot=no,fastboot.forceFastBoot=yes to enable snapshots.
  • hw.lcd.density: Virtual display DPI.
  • hw.lcd.width,hw.lcd.height: Virtual display dimensions.
  • hw.ramSize: RAM limit for the guest. (2GB minimum)

How to wipe data

Remove all userdata*.img files in /Applications/Android\ Emulator.app/Contents/MacOS/aosp-master-arm64-v8a/.

How to build your own emulator

Building the engine

The emulator source code lives (here), but there are a bunch of other dependencies to download, so we use repo.

To build, first make sure you have Xcode and Xcode command line tools installed, and that you have Chromium depot_tools in your PATH (link). Then:

mkdir emu
cd emu
repo init -u https://android.googlesource.com/platform/external/qemu --depth=1
repo sync -qcj 4
cd external/qemu
python android/build/python/cmake.py --target=darwin_aarch64

Note that canceling the python based build after it gets going and issuing just ninja -C objs install/strip may be faster.

The built artifacts are in /path/to/external/qemu/objs/distribution/emulator. They should be automatically signed. However, the binaries in objs/ are not; to sign them, issue ./sign-objs-binaries.sh. Note that this can only be done after ninja -C objs install/strip is successful.

Building the system image

The system image is built from AOSP master sdk_phone_arm64 with a few modifications. Ideally, let's be on a Linux host when building the system image---the build is relatively untested on M1 systems, and at least, we need to create a separate case sensitive partition for the AOSP repo. Assuming you're on Linux:

mkdir aosp-master
cd aosp-master
repo init -u https://android.googlesource.com/platform/manifest -b master --depth=1
repo sync -qcj 4

We first need to make an edit to remove all 32 bit support. Patch this change: link to build/make/target/board/emulator_arm64/BoardConfig.mk. Then:

source build/envsetup.sh
lunch sdk_phone_arm64-userdebug
make -j12

After that's done, we can use this script to package up the system image for use in /Applications/Android\ Emulator.app/Contents/MacOS/aosp-master-arm64-v8a/. Assuming you're still in the Android build environment:

echo $ANDROID_PRODUCT_OUT
export ZIPPED_NAME=$1
mkdir -p $ZIPPED_NAME/files
cd $ZIPPED_NAME/files
cp $ANDROID_PRODUCT_OUT/system-qemu.img system.img
cp $ANDROID_PRODUCT_OUT/vendor.img vendor.img
cp $ANDROID_PRODUCT_OUT/ramdisk.img ramdisk.img
cp $ANDROID_PRODUCT_OUT/ramdisk.img ramdisk.img
if [ -f $ANDROID_PRODUCT_OUT/kernel-ranchu-64 ]; then
    cp $ANDROID_PRODUCT_OUT/kernel-ranchu-64 kernel-ranchu-64
else
    cp $ANDROID_PRODUCT_OUT/kernel-ranchu kernel-ranchu
fi;
cp -r $ANDROID_PRODUCT_OUT/data .
cp -r $ANDROID_PRODUCT_OUT/advancedFeatures.ini advancedFeatures.ini
cp -r $ANDROID_PRODUCT_OUT/userdata.img .
cp -r $ANDROID_PRODUCT_OUT/encryptionkey.img .
cp -r $ANDROID_PRODUCT_OUT/build.prop .
mkdir system
cp -r $ANDROID_PRODUCT_OUT/build.prop system/build.prop
cp -r $ANDROID_PRODUCT_OUT/VerifiedBootParams.textproto .
cp -r $ANDROID_PRODUCT_OUT/source.properties .

cd ..
zip -1rq $ZIPPED_NAME.zip files
ls -l $ZIPPED_NAME.zip

Then, $ZIPPED_NAME.zip can be sent over to the M1 and the contents of its files/ can be coped over into /Applications/Android\ Emulator.app/Contents/MacOS/aosp-master-arm64-v8a/.

android-emulator-m1-preview's People

Contributors

741g avatar lfy 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-emulator-m1-preview's Issues

APK failed to install

The APK failed to install.
Error: INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113

I'm a developer of server ,how can i fix it without changing apk package 😭

No internet access

Can't connect to internet on my emulator when my MAC M1 is connected to personal hotspot on my iPhone.

webview cann't load any url.

webview cann't load any url.
return net::ERR_CLEARTEXT_NOT_PERMITTED

Name: <build>
CPU/ABI: arm64
Path: /Applications/Android Emulator.app/Contents/MacOS/api30-gphone-arm64-v8a
Target: google_apis [Google APIs] (API level 30)
Skin: 1080x1920
SD Card: <none>
avd.ini.displayname: s
avd.ini.encoding: UTF-8
disk.dataPartition.size: 2048M
fastboot.chosenSnapshotFile: 
fastboot.forceChosenSnapshotBoot: no
fastboot.forceColdBoot: yes
fastboot.forceFastBoot: no
hw.accelerometer: yes
hw.arc: false
hw.audioInput: yes
hw.battery: yes
hw.camera.back: virtualscene
hw.camera.front: emulated
hw.cpu.ncore: 2
hw.dPad: no
hw.device.hash2: MD5:55acbc835978f326788ed66a5cd4c9a7
hw.device.manufacturer: Google
hw.device.name: pixel_2
hw.gps: yes
hw.gpu.enabled: yes
hw.gpu.mode: auto
hw.initialOrientation: Portrait
hw.keyboard: yes
hw.lcd.density: 420
hw.lcd.height: 1920
hw.lcd.width: 1080
hw.mainKeys: no
hw.ramSize: 2048
hw.sdCard: no
hw.sensors.orientation: yes
hw.sensors.proximity: yes
hw.trackBall: no
runtime.network.latency: none
runtime.network.speed: full
showDeviceFrame: yes
tag.display: Google APIs
tag.id: google_apis
vm.heapSize: 256

screenshot

Audio

@741g
Related to this change, does the audio should works now ?
I observed neither audio-out, nor audio-in works. But I only tested with first version

No Google Play Store

There is google play store, so we cannot test for google maps etc.

How to install play store in emulator.

MediaPlayer.setDataSource(path) hangs forever

MediaPlayer.setDataSource(path) hangs forever - there is no exception, it just stays there.

(I know it's an initial preview and it probably has something to do with the media player not working at all, but maybe it's useful).

Root the emulator

Hello, is there any way to root the emulator please? Thank you 👍

The GPS Location is not working

Can't able to fetch location
Location Feature is not working
it is asking for the permission the after that it is stuck on fetching the location

Browsing folder path results in freeze

Whenever I try to browse to a path in the emulator settings the emulator freezes. This happens on both folder icons for "Screenshot Save Location" and "Use Detected ADB Location".

Is writable-system supported?

Hello, is the writable-system option supported? If so, how can I pass it to the emulator? I can't see it in the config.ini file.
And thank you for your work! 😄

Secondary screen not showing.

To be honest, I don't know if I am doing something wrong here or if this is a bug.

I am trying to setup a second screen, mainly cause the resolution of the primary screen can not be customized. The second screen is never shown in the emulator, independant from using a custom or preset resolution.

Can't edit emulator's density

I'm trying to create an emulator with a different density , but whenever i assign a new value for hw.lcd.density which isn't 420 (the default value) the emulator won't open

Attempting to change ADB path causes spinning wheel of death

I hadn't downloaded ADB so it didn't detect a location, once I had downloaded I couldn't then manually select a location as it pinwheels and I have to kill the app. It isn't possible to simply type into the path box either.

M1 MacBook Air, 16GB / 512GB, macOS 11.1

Build own Emulator/engine

Following this https://github.com/741g/android-emulator-m1-preview#building-the-engine on a Ubuntu 20.04 and macOS 12.0.1 I run into this

hannes@Latitude aosp $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
Cloning into 'depot_tools'...
remote: Sending approximately 33.41 MiB ...
remote: Total 47584 (delta 35512), reused 47584 (delta 35512)
Receiving objects: 100% (47584/47584), 33.41 MiB | 9.37 MiB/s, done.
Resolving deltas: 100% (35512/35512), done.
hannes@Latitude aosp $ pwd
/home/hannes/aosp
hannes@Latitude aosp $ ~/.bashrc
-bash: /home/hannes/.bashrc: Permission denied
hannes@Latitude aosp $ vi ~/.bashrc
hannes@Latitude aosp $ pwd
/home/hannes/aosp
hannes@Latitude aosp $ vi ~/.bashrc
hannes@Latitude aosp $ source ~/.bashrc
hannes@Latitude:~/aosp$ mkdir emu
hannes@Latitude:~/aosp$ cd emu
hannes@Latitude:~/aosp/emu$ repo init -u https://android.googlesource.com/platform/external/qemu --depth=1
Downloading Repo source from https://chromium.googlesource.com/external/repo
remote: Counting objects: 287, done
remote: Total 7669 (delta 4924), reused 7669 (delta 4924)
Receiving objects: 100% (7669/7669), 3.63 MiB | 7.92 MiB/s, done.
Resolving deltas: 100% (4924/4924), done.
repo: Updating release signing keys to keyset ver 2.3
Downloading manifest from https://android.googlesource.com/platform/external/qemu
remote: Counting objects: 2633, done
remote: Finding sources: 100% (2633/2633)
remote: Total 2633 (delta 500), reused 1724 (delta 500)
Receiving objects: 100% (2633/2633), 6.06 MiB | 7.31 MiB/s, done.
Resolving deltas: 100% (500/500), done.
fatal: manifest 'default.xml' not available
fatal: manifest default.xml not found
hannes@Latitude:~/aosp/emu$ repo sync -qcj 4
fatal: error parsing manifest /home/hannes/aosp/emu/.repo/manifest.xml: [Errno 2] No such file or directory: '/home/hannes/aosp/emu/.repo/manifest.xml'

any ideas ?

Emulator does not start (wrong dylib path)

I have tried to run this on Apple Silicon macOS 11.0.1 (20B29). After moving to Application folder it was bouncing for a while, then got blocked by macOS (unknown dev). After allowing it in Security settings it does not start at all.

No error messages.
No processes in Activity Monitor.
No logs in Console (I think, not sure where to look).

Any way I can try to debug this?

How do i open it please help

I dragged the download to application and all of the instructions and its opening something called "emulator" help

Hangs when selecting adb folder

When unchecking use detected adb location and pressing the folder icon it opens the finder window. Then about 100ms after that, it hangs and you can't select any folder.

Running on M1 Macbook air.

In the mean time is there any other way to get it to load the correct adb path without using this finder file select?

32 bit ARM support?

I know macOS does not support 32-bit apps after version 10.15. But do we have any chance to run 32-bit apps in the Android Emulator either native or emulating? Thanks.

No Maps UI in emulator

Hi guys, so on my intel based computer the Location section of the emulator is as follows

image

But on my m1 emulator its different and the location section doesnt really work

image

What do I have to do to have the maps ui?
Whenever I try running a x86 image it says Process Terminated and doesn't boot up the emulator

Could it use camera?

when I open camera, it is showing like this, could it use the camera from my computer's camera?
Screenshot_1609996847

No android TV support on M1 Mac

As we are developing an app for Android TV and when I try to run the TV emulator from the android studio in Macbook Pro M1, I am getting only one thing the AVD process was killed. I tried all the possible ways to overcome the issue, free up almost 50+ GB of space. But in the end, nothing works. I am trying to run this on the ARM structure. Please tell me, what should I do now?

Install build-tools: emulator not found

When I try to install the build-tools on my M1 Mac, I get an error saying that the emulator does not exist and is a dependancy. Is the emulator published in some channel that I can use when installing the build-tools? Or can I install the build-tools without the emulator?

When I run for example

sdkmanager "build-tools;30.0.3"

I get

Warning: Dependant package with key emulator not found!
Warning: Unable to compute a complete list of dependencies.

I don't need the actual emulator, I only need to build my project and run it on a physical device

Screenshot resulting in blank PNG

Whenever I try to make a screenshot the result is an "empty" or "white" PNG File. This is independant from the choosen resolution, density or open app.

Example:
Screenshot_1607602370

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.