This project contains a Grunt plugin which includes tasks to:
- Create an Android emulator
- Start an Android emulator
- Stop an Android emulator
- Unlock an Android emulator
- Install an APK
- Start an activity
This plugin requires Grunt ~0.4.1
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-android-emulator --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-android-emulator');
This task creates an Android emulator. You can execute it using:
grunt create-android-emulator:emulator-1
where emulator-1
is a the emulator's id as shown in the below configuration.
grunt.initConfig({
grunt_android_emulator: {
emulators: [{
id: 'emulator-1',
create: {
'--name': 'testAVD',
//'--sdcard': '10M',
//'--snapshot': '',
//'--path': 'avd',
'--force': '',
//'--skin': '',
'--target': 'android-18',
'--abi': 'armeabi-v7a'
}
}]
}
});
Type: String
Description: Name of the new AVD
Usage: [required]
Type: String
Description: Target ID of the new AVD
Usage: [required]
Type: String
Description: Directory where the new AVD will be created
Usage: [optional]
Type: -
Description: Forces creation (overwrites an existing AVD)
Usage: [optional]
Type: String
Description: Skin for the new AVD
Usage: [optional]
Type: String
Description: Device definition to use
Usage: [optional]
Type: String
Description: The ABI to use for the AVD
Usage: [optional]
Type: String
Description: Path to a shared SD card image, or size of a new sdcard for the new AVD
Usage: [optional]
Type: String
Description: Place a snapshots file in the AVD, to enable persistence
Usage: [optional]
This task starts an Android emulator. You can execute it using:
grunt start-android-emulator:emulator-1
where emulator-1
is a the emulator's id as shown in the below configuration.
grunt.initConfig({
grunt_android_emulator: {
emulators: [{
id: 'emulator-1',
start: {
'-port': '5556',
//'-no-window': '',
'-no-audio': '',
// '-force-32bit': ''
//'-no-boot-anim': '',
//'-no-skin': '',
//'-memory': '1024'
//'-avd': 'testAVD'
}
}],
}
});
Type: String
Description: TCP port that will be used for the console
Usage: [optional]
Default: 5554
Type: String
Description: Physical RAM size in MB
Usage: [optional]
Type: String
Description: AVD name
Usage: [optional]
Default: The --name or -n value of the emulator's create options
Type: -
Description: Disable audio support
Usage: [optional]
Type: -
Description: Don't use any emulator skin
Usage: [optional]
Type: -
Description: Disable animation for faster boot
Usage: [optional]
Type: -
Description: Disable graphical window display
Usage: [optional]
Execute emulator -help
in a terminal to see a list of the available options. Note that the -ports option is not supported
This task stops an Android emulator. You can execute it using:
grunt stop-android-emulator:emulator-1
where emulator-1
is a the emulator's id.
This task unlocks an Android emulator. You can execute it by using:
grunt unlock-android-emulator:emulator-1
where emulator-1
is a the emulator's id.
The plugin uses the -port
option of the start
options to find the emulator to stop or 5554 in case this option is not defined.
This task installs an APK in an Android emulator. You can execute it using:
grunt install-apk:emulator-1:apk-1
where emulator-1
is a the emulator's id and apk-1 is the APK's id as shown in the below configuration.
grunt.initConfig({
grunt_android_emulator: {
emulators: [{
id: 'emulator-1',
create: {
'--name': 'testAVD',
//'--sdcard': '10M',
//'--snapshot': '',
//'--path': 'avd',
'--force': '',
//'--skin': '',
'--target': 'android-18',
'--abi': 'armeabi-v7a'
}
}],
apks: [{
id: "apk-1",
path: "./apk/test.apk",
activities: [{
id: "activity-1",
packageName: "org.jboss.aerogear",
name: "AeroGearMain"
}]
}]
}
});
Type: String
Description: Relative or absolute path of the APK
Usage: [required]
This task starts an activity. You can execute it using:
grunt start-activity:emulator-1:apk-1:activity-1
where emulator-1
is a the emulator's id, apk-1 is the APK's id and activity-1 is the activity's id as shown in the below configuration.
grunt.initConfig({
grunt_android_emulator: {
emulators: [{
id: 'emulator-1',
create: {
'--name': 'testAVD',
//'--sdcard': '10M',
//'--snapshot': '',
//'--path': 'avd',
'--force': '',
//'--skin': '',
'--target': 'android-18',
'--abi': 'armeabi-v7a'
}
}],
apks: [{
id: "apk-1",
path: "./apks/test.apk",
activities: [{
id: "activity-1",
packageName: "org.jboss.aerogear",
name: "AeroGearMain"
}]
}]
}
});
Type: String
Description: Identifier of the activity
Usage: [required]
Type: String
Description: Package name
Usage: [required]
Type: String
Description: Activity name
Usage: [required]
The example folder contains a sample example which depicts how to use this plugin.
Released 12 March 2017
- Fix bug during starting activities
Released 16 January 2016
- Update shelljs dependency NPM version
Released 08 September 2014
- Remove validation from create options --device option support
Released 13 December 2013
- Add APK installation and start activity support
Released 20 October 2013
- Initial release