How to detect and run code specific to Genymotion Emulators

When you are running test you might need to differentiate for specific environments. For example, if you haven’t patched your Genymotion emulators to include the missing Google Apps you would need to skip any tests that use Google Play Services like for ti.map.

To detect which emulator you are running your code in, you can use Ti.Platform.manufacturer, which returns unknown on Android Virtual Devices, but Genymotion on Genymotion emulators.

Example Code

var isGenymotion = (Ti.Platform.name === 'android' && Ti.Platform.manufacturer === 'Genymotion');

var win = Ti.UI.createWindow();

win.add(Ti.UI.createLabel({
  text: 'You ' + (isGenymotion ? 'ARE' : 'ARE NOT') + ' using Genymotion.\n' +
        'The manufacturer is: ' + Ti.Platform.manufacturer
}));

win.open();

Genymotion

Reconsider using AVDs

Genymotion became a popular alternative for the infamous slow AVDs. However, you might want to reconsider. Most of them include Google APIs, the performance has improved a lot recently and Android Studio makes it very easy to manage AVDs for tons of common devices:

AVD

And yes, these AVDs work fine with Titanium!

Code Strong! ?

3 COMMENTS

  1. Just a quicky then, is “all” I have to do install Android Studio, considering I now have a fully working environment? Also considering I am in production….

Comments are closed.