logo Android Maven Plugin - android-maven-plugin

Maven Plugin for Android Development

homepage: code.google.com/p/maven-android-plugin
fresh index:
last release: 7 years ago, first release: 1 decade ago
packaging: maven-plugin
get this artifact from: central
see this artifact on: search.maven.org


Display vulnerabilities (snyk): Vulnerability check

This chart shows how much is this artifact used as a dependency in other Maven artifacts in Central repository and GitHub:


select version:

Add this snippet into pom.xml inside tag <project><build><plugins>:




Switch to artifact.
goals:
android:aar (phase: verify)

Creates an Android Archive (aar) file.

android:apk (phase: package)

Creates the apk file. By default signs it with debug keystore. Change that by setting configuration parameter <sign><debug>false</debug></sign>.

android:apklib (phase: package)

Creates the apklib file. apklib files do not generate deployable artifacts.

android:clean (phase: clean)
android:connect

Connect external IP addresses to the ADB server.

android:deploy (phase: pre-integration-test)

Deploys the apk(s) of the current project(s) to all attached devices and emulators. Automatically skips other projects in a multi-module build that do not use packaging apk without terminating. Deploymnet is automatically performed when running mvn integration-test (or mvn install) on a project with instrumentation tests.

android:deploy-apk

Deploys a specified Android application apk to attached devices and emulators. By default it will deploy to all, but a subset or single one can be configured with the device and devices parameters.This goal can be used in non-android projects and as standalone execution on the command line.

android:deploy-dependencies

Deploys all directly declared dependencies of <type>apk</type> in this project's pom. Usually used in a project with instrumentation tests, to deploy the apk to test onto the device before running the deploying and running the instrumentation tests apk. Automatically performed when running mvn integration-test (or mvn install) on a project with instrumentation tests.

android:devices

DevicesMojo lists all attached devices and emulators found with the android debug bridge. It uses the same naming convention for the emulator as used in other places in the Android Maven Plugin and adds the status of the device in the list. TODO The goal is very simple and could be enhanced for better display, a verbose option to display and to take the android.device paramter into account.

android:dex (phase: prepare-package)

Converts compiled Java classes to the Android dex format.

android:disconnect

Disconnect external IP addresses from the ADB server.

android:emma (phase: prepare-package)

After compiled Java classes use emma tool

android:emulator-start

EmulatorStartMojo can start the Android Emulator with a specified Android Virtual Device (avd).

android:emulator-stop

EmulatorStartMojo can stop the Android Emulator with a specified Android Virtual Device (avd).

android:emulator-stop-all

EmulatorStopeAllMojo will stop all attached devices.

android:generate-sources (phase: generate-sources)

Generates R.java based on resources specified by the resources configuration parameter. Generates java files based on aidl files.

android:help

Display help information on android-maven-plugin. Call mvn android:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.

android:instrument

Runs the instrumentation apk on device.

android:internal-integration-test (phase: integration-test)

Internal. Do not use. Called automatically when the lifecycle reaches phase integration-test. Figures out whether to call goals in this phase; and if so, calls android:instrument.

android:internal-pre-integration-test (phase: pre-integration-test)

Internal. Do not use. Called automatically when the lifecycle reaches phase pre-integration-test. Figures out whether to call goals in this phase; and if so, calls android:deploy-dependencies and android:deploy.

android:lint

LintMojo can run the lint command against the project. Implements parsing parameters from pom or command line arguments and sets useful defaults as well. Warning, if you use android.lint.enableClasspath and/or android.lint.enableLibraries the behavior of this goal will vary depending on the phase where this goal is executed. See android.lint.classpath/lintClassPath and android.lint.libraries/lintLibraries for more details.

android:manifest-update (phase: process-resources)

Updates various version attributes present in the AndroidManifest.xml file.

android:monkey

Can execute tests using UI/Application Exerciser Monkey. Implements parsing parameters from pom or command line arguments and sets useful defaults as well. This goal will invoke Android Monkey exerciser. If the application crashes during the exercise, this goal can fail the build. A typical usage of this goal can be found at Quality tools for Android project.

android:monkeyrunner

Can execute monkey runner programs. Implements parsing parameters from pom or command line arguments and sets useful defaults as well. This goal will invoke monkey runner scripts. If the application crashes during the exercise, this goal can fail the build. A typical usage of this goal can be found at Quality tools for Android project.

android:ndk-build (phase: compile)
android:proguard (phase: process-classes)

Processes both application and dependency classes using the ProGuard byte code obfuscator, minimzer, and optimizer. For more information, see https://proguard.sourceforge.net.

android:pull

Copy file or directory from all the attached (or specified) devices/emulators.

android:push

Copy file to all the attached (or specified) devices/emulators.

android:redeploy

Undeploys and the deploys (= redeploys) the apk(s) of the current project(s) to all attached devices and emulators. Automatically skips other projects in a multi-module build that do not use packaging apk without terminating.

android:redeploy-apk

Reploys a specified Android application apk to attached devices and emulators. By default it will deploy to all, but a asubset or single one can be configured with the device and devices parameters. This simply tries to undeploy the APK first and then deploy it again. This goal can be used in non-android projects and as standalone execution on the command line.

android:run

Runs the first Activity shown in the top-level launcher as determined by its Intent filters. Android provides a component-based architecture, which means that there is no "main" function which serves as an entry point to the APK. There's an homogeneous collection of Activity(es), Service(s), Receiver(s), etc. The Android top-level launcher (whose purpose is to allow users to launch other applications) uses the Intent resolution mechanism to determine which Activity(es) to show to the end user. Such activities are identified by at least: Action type: android.intent.action.MAIN Category: android.intent.category.LAUNCHER And are declared in AndroidManifest.xml as such: <activity android:name=".ExampleActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> This {@link Mojo} will try to to launch the first activity of this kind found in AndroidManifest.xml. In case multiple activities satisfy the requirements listed above only the first declared one is run. In case there are no "Launcher activities" declared in the manifest or no activities declared at all, this goal aborts throwing an error. The device parameter is taken into consideration so potentially the Activity found is started on all attached devices. The application will NOT be deployed and running will silently fail if the application is not deployed.

android:uiautomator

Can execute tests using ui uiautomator. Implements parsing parameters from pom or command line arguments and sets useful defaults as well. This goal is meant to execute a special java project dedicated to UI testing via UIAutomator. It will build the jar of the project, dex it and send it to dalvik cache of a rooted device or to an emulator. If you use a rooted device, refer to this thread on stack over flow. The tests are executed via ui automator. A surefire compatible test report can be generated and its location will be logged during build. To use this goal, you will need to place the uiautomator.jar file (part of the Android SDK >= 16) on a nexus repository. A typical usage of this goal can be found at Quality tools for Android project.

android:undeploy

Undeploys the apk(s) of the current project(s) to all attached devices and emulators. Automatically skips other projects in a multi-module build that do not use packaging apk without terminating. Deploymnet is automatically performed when running mvn integration-test (or mvn install) on a project with instrumentation tests.

android:undeploy-apk

Undeploys a specified Android application apk from attached devices and emulators. By default it will undeploy from all, but a subset or single one can be configured with the device and devices parameters. You can supply the package of the application and/or an apk file. This goal can be used in non-android projects and as standalone execution on the command line.

android:unpack

Unpack libraries code and dependencies into target. This can be useful for using the proguard maven plugin to provide the input jars. Although it is encouraged to use the proguard mojo of the android maven plugin.

android:zipalign

ZipalignMojo can run the zipalign command against the apk. Implements parsing parameters from pom or command line arguments and sets useful defaults as well.

Often used code snippets:

<plugin>
  <groupId>com.jayway.maven.plugins.android.generation2</groupId>
  <artifactId>android-maven-plugin</artifactId>
  <extensions>true</extensions>
</plugin>
<plugin>
  <groupId>com.jayway.maven.plugins.android.generation2</groupId>
  <artifactId>android-maven-plugin</artifactId>
  <configuration>
    <sdk>
      <platform>16</platform>
    </sdk>
  </configuration>
</plugin>
<plugin>
  <groupId>com.jayway.maven.plugins.android.generation2</groupId>
  <artifactId>android-maven-plugin</artifactId>
  <extensions>true</extensions>
  <configuration>
    <nativeLibrariesDirectory>ignored</nativeLibrariesDirectory>
  </configuration>
</plugin>
<plugin>
  <groupId>com.jayway.maven.plugins.android.generation2</groupId>
  <artifactId>android-maven-plugin</artifactId>
  <configuration>
    <sdk>
      <platform>19</platform>
    </sdk>
  </configuration>
</plugin>
<plugin>
  <groupId>com.jayway.maven.plugins.android.generation2</groupId>
  <artifactId>android-maven-plugin</artifactId>
  <version>3.1.1</version>
  <configuration>
    <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
    <assetsDirectory>${project.basedir}/assets</assetsDirectory>
    <resourceDirectory>${project.basedir}/res</resourceDirectory>
    <nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
    <sdk>
      <platform>10</platform>
    </sdk>
    <undeployBeforeDeploy>true</undeployBeforeDeploy>
  </configuration>
  <extensions>true</extensions>
</plugin>

© Jiri Pinkas 2015 - 2022. All rights reserved! Admin login To submit bugs / feature requests please use this github page
related: JavaVids | Top Java Blogs | Java školení
Apache and Apache Maven are trademarks of the Apache Software Foundation. The Central Repository is a service mark of Sonatype, Inc.