Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 40 Next »

You can use an android emulator to help you develop your GDSL tests. It is usefull if you do not have a real device or if you want to test on a device with the same resolution as a device on the Test Bench. Do not use emulator if you want measures, the metrics (energy, data …) are not available.

1. Use an android emulator without Greenspector tools

1.1. Prerequisite

  • 16 GB of RAM memory

  • Install Android Studio

  • Install Java on Linux

# Update the repositories
sudo apt-get update

# Check if Java is already installed
java -version

# Install Java Runtime Environment (JRE) and verify the installation
sudo apt-get install openjdk-8-jre
java -version

# To change the java version used
sudo update-alternatives --config java
  • Install Java on Window:

1.2. Create an emulator

  • Open Android Studio

  • Click on the three dots button

  • Select Virtual Device Manager

If you already have a project open on Android Studio, click on Tools > Device Manager.

  • On the Device Manager window, click on “Create Device”

  • On the Virtual Device Configuration window, click on “New Hardware Profile”

  • Fill in the form with the properties of the device you want to create. In the example below, you can find the properties of the Samsung Galaxy S9.

If you want to use a tablet emulator, you can uncheck the portrait mode to use only the landscape mode.

Click on “Finish” then on “Next”.

  • Select a System Image, for example Android 10.0 (Google APIs). Click on “Next”.

  • Check the configuration and click on “Finish”. Be careful, the configuration might be different than the one you chose. Make sure to click on “Show Advanced Settings” and check each property.

  • Your device is now created. You can launch it by clicking on the triangle.

1.3. Emulators tested

Device Name

Screen Size

(inches)

Resolution

RAM

System image

Version Chrome

Computer OS

Samsung Galaxy S9

5.8

1080 x 2220

4 GB

Android 10.0 Google APIs | x86

113

Linux

Samsung Galaxy Tab A7

10.4

2000 x 1200

3 GB

Android 10.0 Google APIs | x86

114

Linux

Samsung Galaxy Tab S7 FE

12.4

2560 x 1600

4 GB

Android 13.0 Google APIs | x86_64

114

Linux

Samsung Galaxy S10

6.1

1080 x 2280

8 GB

Android 11.0 Google APIs | x86

Google Pixel C

10.2

2560 x 1800

(à vérifier)

3 GB

Android 8.1 Google APIs | x86

1.4. Add Google Play Store to a custom emulator

  • Open the file $HOME/.android/avd/[device_id]/config.ini. Replace [device_id] by the id of your device.

On Windows, it is located in C:\Users\[user_name]\.android\avd\[device_id]\config.ini

  • Make the following changes:

    • PlayStore.enabled: change from “false” to “true”

    • image.sysdir.1: change “google_apis” to “google_apis_playstore”

    • tag.display: change “Google APIs” to “Google Play”

    • tag.id: change “google_apis” to “google_apis_playstore”

  • Save your changes

  • On the Device Manager window, select the three dots button and click on “Wipe Data”. It will load the new configuration.

  • We expect the following error message:

  • Install sdkmanager from Android Studio:

    • Click on More Actions > SDK Manager (or Tools > SDK Manager if a project is open)

    • Click on the SDK Tools tab, uncheck "Hide Obsolete Packages"

    • Check Android SDK Tools and install version 26.1.1

  • Add sdkmanager to your path:

    • On Linux: add the line export PATH=$HOME/Android/Sdk/tools/bin:$PATH in the .bashrc file and run the command "source ~/.bashrc"

    • On Mac: add the line export PATH=$HOME/Library/Android/sdk/tools/bin:$PATH in the .bash_profile file and run the command "source ~/.bash_profile"

    • On Windows: Settings > System > About > Advanced settings > Environment variables > Path > Modify > Add the path C:\Users\[username]\AppData\Local\Android\Sdk\tools\bin

  • Ajouter “adb” en tant que variable d’environnement :

  • Install the system image with Google Play Store:

# For Android 10.0
sdkmanager --install "system-images;android-29;google_apis_playstore;x86"
# For Android 11.0
sdkmanager --install "system-images;android-30;google_apis_playstore;x86"
# For Android 13.0
sdkmanager --install "system-images;android-33;google_apis_playstore;x86_64"

To see the list of available system images, run the command “sdkmanager --list”.

  • On the Device Manager window, select the three dots button and click on “Wipe Data”. It will load the new configuration. Then, you can launch the device with Google Play Store.

1.5. Update Google Play Store and Google Chrome

  • Start the emulator

  • Open Google Play Store

  • Sign in with your account

  • Click on your profile at the top right of the emulator screen

  • Click on Settings > About > Update Play Store

  • Wait for the update to complete. It takes several minutes.

  • If you want to test a website, search for the Google Chrome app and update it

1.6. Start an emulator from the command line (optional)

  • On Linux: Update ~/.bashrc or ~/.zshrc

# For newer version of Android SDK
export PATH=$HOME/Android/Sdk/emulator:$PATH

# For older version of Android SDK
export PATH=$HOME/Android/Sdk/tools:$PATH
  • On macOS: Update ~/.bashrc or ~/.bash_profile

export PATH=$HOME/Library/Android/Sdk/emulator:$PATH
  • On Windows:

    • Settings > System > System Information > Advanced system settings

    • Add “C:\Users\[user_name]\AppData\Local\Android\Sdk\emulator” to path

  • To see the list of emulators

emulator -list-avds
  • To start en emulator

emulator -avd [avd_name]

If an emulator crashes or is too slow, you can try one of the following commands:

emulator -avd [avd_name] -memory 8000

emulator -avd [avd_name] -gpu shiftshader_indirect

To get more logs, you can use the following command:

emulator -avd [avd_name] -logcat-output logcat.txt -debug all -verbose

2. Use an android emulator with Greenspector tools

2.1. Prerequisite

  • Follow the first part of the documentation

  • Install ADB (Android Debug Bridge) and add it to your path

  • Get the testrunner from https://app.greenspector.com/ in the Modules tab, and put it in a folder (for example “testrunner_files”)

  • Add in this folder the configuration files config.yml and job.yml, and a script with the testgb extension. An example of these files is available at the following location:

2.2. Change the job.yml file

job:
  extras:
    config-skipsetupphone: true

2.3. Change the config.yml file

target:
  connection: usb
  serial: xxxx

The target.serial field corresponds to the emulator id. You can find it by running “adb devices”.

2.4. Get the android-service executable in 32 bits

  • Download the android-service executable in 32 bits and its version file : https://dl.greenspector.com/emulator/android-service-files.tar.gz

  • Go to your greenspector cache:

    • On Linux and macOS: $HOME/.greenspector

    • On Windows: C:\Users\[username]\.greenspector

  • Replace the android-service and android-service.version files with the downloaded files. You will have to decompress the tar.gz file.

  • You can now run the testrunner with the following command

./testrunner -jobFile job.yml -config config.yml --no-update

If you forget the --no-update option, you have to replace the android-service and android-service.version files again.

  • No labels