Dear friendy reader,

nice to see you around here. I publish these articles for free and it would be very kind of you to support my blog. You can start by disabling your AdBlocker. That would mean a lot to me and will help to finance this blog.

Best regards, J. Wiese

Unity 3D: Testing Android builds with an emulator

Using an emulator to test your Android builds can really speed up your development. Unity can build the app automatically and push it to your preferred emulator. Testing your product with powerful hardware can be a key in production. There are several emulators out in the wild and I’ll review some of them.

Android SDK

Obviously, the source for an emulator is shipped by the Android SDK (only SDK download is at the very bottom). If you are already developing for android, the SDK will be already installed on your system. Open up the SDK-Manager and download one of the latest emulation images. If you are running windows as operating system, you may need to make sure, that Hyper-V is not installed. Otherwise, you will end with a bluescreen after starting the emulator. Hyper-V can be removed with the windows features manager.

UPDATE12.07.18: With the latest Windows 10 April 2018 Update and the latest beta image from google, the Hyper-V technology IS supported. As AMD user you may want to switch now, to gain the advantage of the hardware acceleration. If you use Hyper-V, do not install HAXAM!

> Press WIN+R -> enter "OptionalFeatures.exe" -> OK -> Uncheck Hyper-V -> OK -> Restart PC

To speed up the emulator, install Intel HAXM, but this should tell you the SDK-Manager as well.

Afterwards, open the AVD Manager and create a suitable virtual device. After starting it, the “Build & Run” command in Unity3D will now automatically push the app onto the emulator and open it. If the root folder of the SDK is not configured within unity, it will ask for the location. To manually change the path navigate to:

> Unity3D -> Edit -> Preferences -> External Tools -> Android SDK

The only missing feature is the multitouch input. You can try to use an actual device as input device for the emulator. Install $android_sdk\tools\apps\SdkController\bin\SdkControllerApp.apk onto your phone and open it. Follow the instructions in the app to connect your device with the emulator.

*Nox Player

The next Android emulator is the Nox App Player. It is a feature rich player based on Android 4.4.2. Due to many optimizations it starts incredibly fast and runs very smooth. It offers many cool features, like a shared folder, video recording and the google play store. The player supports multiple instances, so the testing of multiplayer applications should be a lot easier.

The player has a way better input & sensor emulation as the other above. Multitouch events can easily be emulated. Keyboard keys can be mapped with clicks at specified screen coordinates. You can record touch inputs as a macro and replay it. Using “WSAD” and a map, you can walk the GPS system. The most of these inputs use nice overlays to display their configuration.

Enable ADB

You only need to activate adb within the instance:

Enable ADB within the NOX Player PT.1

Enable ADB within the NOX Player PT.1

Enable ADB within the NOX Player PT.2

Enable ADB within the NOX Player PT.2

Now run the following command within the shell

> adb connect 127.0.0.1:62001

Bluestacks

The last emulator on my list is the bluestacks app player. This emulator is one of the first commercial ones for Android apps. The latest version(3) is based on Android 4.4.1. The startup is as fast as the Nox-Player. After the first startup, you are required to login with your Google account. The play store is preinstalled, but you can only install games. The player supports multiple instances and you can take screenshots. Important to mention, from time to time the player shows you an advert.

Multiple input events can be mapped with the keyboard and the mouse. Multitouch input can be difficult because you can only use the mapped events and your mouse. Pinch-To-Zoom is supported with Ctrl + MouseWheel. You can set your location on a map. It supports the emulation of the acceleration sensor.

Enable ADB

The player does not auto-connect to ADB. After booting up the emulator, simply run the following command:

adb connect 127.0.0.1:5555

Unity should now push the builds to the emulator.

Visual Studio Emulator for Android (not working)

Unity’s own tutorials provide us with an example of the Visual Studio Emulator for Android. It sounds pretty easy, but after trying it, I challenged with multiple errors. One cool thing about the “Visual Studio Emulator” is the nice support of multiple touch inputs and the one-click installation. It makes use of Intel’s Hyper-V technologies, which provides you with a really fast environment. Furthermore, the emulator can emulate multiple API levels and it auto connects to the ADB tool. This allows Unity3D to automatically push the builds onto the virtual device.

With the Verison 5.6.1 of Unity, the described way is not working for me. The first problem was, that any application built with unity crashes at startup without any useful logcat entry. Only the popup with the text “ has stopped.” showed up. After digging at the unity forums, two changes fixed the crash:

  • Disable Auto Graphics API
  • At Graphics API: Switch OpenGLES2 to the first position

But the game wasn’t starting either. The next problem was, that the unity game freezes at the loading screen. After trying out multiple build settings, the problem remained. So there must be another solution.

You want to comment on this post?
Send an email to: bloginput@jwiese.eu