Search code examples
androidmavenandroid-emulatorandroid-maven-plugin

how to specify the target device (or emulator) on the command line with android maven plugin?


The question is basically what are the arguments that I need to pass in the command line in order to specify the target device (or emulator) with android maven plugin.


Solution

  • You basically just need to pass the argument -Dandroid.device=

    For the device argument, you can use:

    • "usb" (will target the device connected in your usb port)
    • "emulator" (will target the running emulator)
    • specificdeviceid (can be the port number or device name for the emulator or id of the device)

    By the way, if you have more than one target that matches the argument (like 2 emulators running and you use "emulator", it will target all the running emulators). That's pretty handy if you want to deploy in multiple emulators =D

    Just in case, here is an example of the usage of the argument:

    mvn android:deploy android:run -Dandroid.device=emulator