Skip to main content
· 8 min read

Create Your Own Android Cloud Emulator

BlogPostImage

Before launching your app, it’s essential to ensure it works across different user devices.

There are a couple of ways to go about testing your application. For Android developers, you can go with an Android Emulator or consider a cloud emulator.

Both options come with immense capabilities and limitations. However, in this article, we weigh the significance and steps to creating your own Android cloud Emulator.

The Android Emulator mimics or simulates Android devices on your PC, allowing you to test your application on Android APIs or other devices without needing different hardware devices.

When getting started, you may need to use advanced Android Emulator features like extended controls on Android Emulator to send data, control apps, change device properties, and more.

Why build your own Android cloud emulator?

Even though the latest version of Android Emulator in Android Studio can simulate a real Android device, this solution has several limitations.

In this case, you may need to build your own Android cloud emulator. Before we discuss building a cloud emulator, here are the limitations of an Android Emulator.

  1. Because most of the virtual device’s performance is affected by the capabilities of your workstation, the emulator will crash and burn if you don’t have enough free disk space at launch.
  2. The Android emulator is not reliable sometimes when it comes to understanding your app interactions with the native device environment e.g. how the front end appears in different brightness levels.
  3. You need a computer equipped with an ARM processor. Without it, you are stuck with a poor emulator which is available on most Android devices.
  4. Setting up hardware acceleration is a complex process, that even experienced developers struggle with. This may lead to performance issues or system failure.
  5. Over time, a library of virtual devices may cram up your workstation considering most of these Android Virtual Device (AVD) managers create several directories that eat up disk space.

On the flip side, the benefits of building your Android Emulator on the cloud are immense. Some of them include;

Flexibility in app development - When working in the cloud, you get easy access to the build system, and can many changes to the app without any limitations come with a local app development emulator.

Safe data storage - While data privacy continues to be important for Android application users, an Android Cloud Emulator enables you to store and retrieve your files safely.

Fast and accessible backups - Aside from storing your app files, the cloud emulator makes data backups easy and safe.

Easy addition of app functions and features - Updating your Android app, or adding any features is easier when using a cloud emulator. Additionally, you can execute collaborative coding to improve build time.

Enhance instant database integration - App testing on a cloud emulator comes with easy database integrations. The tools you need to build, test and ship an Android application on the cloud are all in one place.

Getting started with Android Cloud Emulator

Primarily run on cloud computing services like Google Cloud, AWS, or Azure, the setup make the AAOS Emulator accessible to anyone in the applications project team.

The Android Automotive OS (AAOS) Emulator on the cloud has several benefits:

  • Capability to build a customized AAOS Emulator image for a virtual machine (VM)
  • Use a setup script to create the cloud emulator

Key Cloud Emulator building blocks

Architecture.png

  1. Android Emulator

    The software application allows you to simulate the Android OS on your computer. It enables you to install Android apps on your computer for debugging and more.

  2. Goldfish-webrtc bridge

    This is a Linux application to provide communication between React apps and the AAOS  Emulator.

  3. Android Emulator WebRTC

    It contains React components that can be used to interact with Android Emulator from the browser.

    The emulator will mount a PNG or WebRTC component view to display the current state of the emulator.

  4. Android Emulator container scripts

    A set of minimal scripts to run the emulator in a container of various systems such as Docker. Most are used for external consumption and are compatible with Python versions 2 and 3.

    Android Emulator container scripts.png

    Since the demos are intended to run on a Linux OS, you must meet the following requirements:

  5. JWT Service (JSON Web Token service)

    The idea is that the user obtains a token from this service and presents this token to get access to the emulator.

    The JWT service contains two scripts of interest;

    • gen-passwords.py: Responsible for creating a salted password file and a public and private JWKS store. The public JWKS is to be used by the envoy proxy to verify that the tokens are properly signed.
    • jwt-provider.py: A simple flask rest server that hands out JWT tokens for everyone who can authenticate using Basic Auth.
  6. Turn Server

    This is required only when the Emulator service is running behind firewalls or proxies.

  7. Envoy

    Envoy is an open-source edge and service proxy designed for cloud-native applications.  The proxy service will help in the following ways:

    • Provide HTTPS using a self-signed certificate.
    • Redirect traffic on port 80 (HTTP) to port 443 (https).
    • Act as a gRPC proxy for the emulator.
    • Verify tokens to permit access to the emulator gRPC endpoint.
    • Redirect other requests to the Nginx component, which hosts a React application.

Set up cloud emulator on VM ( virtual machine)

If you are using Google Cloud, to create a GCP ( google cloud platform) project, follow these steps:

  • Go to the Google Cloud console and select a project.
  • See enable, disable, or change billing to ensure its set correctly
  • Enable the API

Android Cloud Emulator system performance tools

For a successful cloud emulator, there are several tools you can use to measure performance metrics before launching your application. These system performance tools include;

  1. Boot time

    Boot time is the average a device takes to be ready to operate after the power has been turned on. You can profile your boot time using the bootanalyze tool.

    Furthermore, for each specific product, modify the config.yaml file to include events you want to search for.

    stop_event: <logcat log message which will terminate log collection after reboot>

    events:

    event1_name: <pattern that matches log message>

    event2_

    There are a couple of ways to optimize boot time on your computer:

    • Enabling and disabling Memory fast training
    • Enabling and disabling Extended Memory Test
  2. App start-up time

    Since users expect the app to respond and load fast, optimizing app start-up time is essential to a better user experience.  Some common app launch times to be aware of and solve include:

    • Inflating large or complex layouts
    • Loading and decoding bitmaps
    • Blocking screen loading on disk or network I/O
    • Garbage collection events
    • Custom splash screens using a dedicated Activity
  3. User Interface ( UI)

    It’s vital to test how users interact with your Android application. Here are some UI tests to conduct;

    Functional testing: does my app do what it's supposed to?

    Performance testing: does it do it quickly and efficiently?

    Accessibility testing: does it work well with accessibility services?

    Compatibility testing: does it work well on every device and API level?

  4. Memory

    You can monitor memory use in two ways;

    • Snapshot in time using meminfo
    • Over time using prostate

    Procstats makes it possible to see how your application behaves over time. This includes the time taken to run the background and memory used during that period.

  5. Central processing unit (CPU)

    You can use Simpleperf - a central processing unit (CPU) profilin tool for Android. However, to inspect your application’s CPU in real-time while interacting with the app, use CPU Profiler. These tools have other several advantages:

    • Smoothen user experience
    • Preserve battery life
    • Inspect the details of recorded methods, functions, and system traces

    Android Emulator container scripts.png

Build an Android Cloud Emulator

Regardless of the advanced Android Emulator features, the limitations outweigh the benefits long-term. For instance, you are limited to the memory disk on your computer.

To avoid app build speed slowing down from such factors, consider a cloud emulator.  An Android Cloud Emulator gives you room to test, debug, and even deploy your application without any worries related to memory space.

Use the above guide to get started with a cloud emulator. Until the next content piece, keep learning, keep coding, and building great Android applications

Authors
Yash Khandelwal
Share

Related Posts