Maven Archetypes for Android development

Overview

android-archetypes

This projects provides several Maven archetypes for Android. Those archetypes allows to quickly bootstrap a Maven project to develop an android application.

These artifacts are based on the android-maven-plugin (http://code.google.com/p/maven-android-plugin/). It currently uses the 3.8.2 version.

The android-quickstart archetype

The quickstart archetype creates a simple android application ready to be deployed on an android device. It's a pretty simple way to initiate an android project:

mvn archetype:generate \
  -DarchetypeArtifactId=android-quickstart \
  -DarchetypeGroupId=de.akquinet.android.archetypes \
  -DarchetypeVersion=1.0.11 \
  -DgroupId=your.company \
  -DartifactId=my-android-application

You can also set three optional properties :

  • The created 'package' with -Dpackage=your.company.android. By default it uses the given groupId.
  • The Android emulator's name to use with -Demulator=my-avd. If none specified the property will be ignored in the pom file.
  • The targeted Android platform with -Dplatform=X. The Android SDK version will be automatically fetched to fit the corresponding API level. Available API Level are 3, 4, 7, 8, 9, 10, 14 and 16. By default, it uses 16 (android 4.1.1.4).

Once generated, the application is ready to be built and deployed (you may need to configure your ANDROID_HOMEenvironment variable to point to your Android SDK). Start an android emulator, or plug an Android dev phone, and launch:

cd my-android-application
mvn clean install android:deploy android:run

The application will be built, deployed and launched on the device.

The android-with-test archetype

This archetype creates a multi-module project containing an android application and a project testing this application (integration tests using instrumentation).

mvn archetype:generate \
  -DarchetypeArtifactId=android-with-test \
  -DarchetypeGroupId=de.akquinet.android.archetypes \
  -DarchetypeVersion=1.0.11 \
  -DgroupId=com.foo.bar \
  -DartifactId=my-android-project \
  -Dpackage=com.foo.bar.android

You can also set three optional properties :

  • The created 'package' with -Dpackage=your.company.android. By default it uses the given groupId.
  • The Android emulator's name to use with -Demulator=my-avd. If none specified the property will be ignored in the pom file.
  • The targeted Android platform with -Dplatform=X. The Android SDK version will be automatically fetched to fit the corresponding API level. Available API Level are 3, 4, 7, 8, 9, 10, 14 and 16. By default, it uses 16 (android 4.1.1.4).

Once generated, the application is ready to be built and tested. Start an android emulator, or plug an Android dev phone, and launch:

cd my-android-project
mvn clean install

The application will be built, then the integration-tests will be built and executed on the Android device. If you whish to launch just the application:

cd my-android-project
mvn clean install android:deploy android:run

The android-library-quickstart archetype

The library quickstart archetype creates a simple Android library ready to be used with another Android application. It's a pretty simple way to initiate an android project:

mvn archetype:generate \
  -DarchetypeArtifactId=android-library-quickstart \
  -DarchetypeGroupId=de.akquinet.android.archetypes \
  -DarchetypeVersion=1.0.11 \
  -DgroupId=your.company \
  -DartifactId=my-android-application

You can also set three optional properties :

  • The created 'package' with -Dpackage=your.company.android. By default it uses the given groupId.
  • The targeted Android platform with -Dplatform=7. The Android SDK version will be automatically fetched to fit the corresponding API level. Available API Level are 3, 4, 7, 8, 9, 10 and 14. By default, it uses 10 (android 2.3.3).

Once generated, the library is ready to be built:

cd my-android-application
mvn clean install

The android-release archetype

This archetype extends android-with-test with release management.

mvn archetype:generate \
  -DarchetypeArtifactId=android-release \
  -DarchetypeGroupId=de.akquinet.android.archetypes \
  -DarchetypeVersion=1.0.11 \
  -DgroupId=com.foo.bar \
  -DartifactId=my-android-project \
  -Dpackage=com.foo.bar.android

You can also set three optional properties :

  • The created 'package' with -Dpackage=your.company.android. By default it uses the given groupId.
  • The Android emulator's name to use with -Demulator=my-avd. If none specified the property will be ignored in the pom file.
  • The targeted Android platform with -Dplatform=X. The Android SDK version will be automatically fetched to fit the corresponding API level. Available API Level are 3, 4, 7, 8, 9, 10, 14 and 16. By default, it uses 16 (android 4.1.1.4).

Once generated, the application is ready to be built and tested. Start an Android emulator, or plug an Android dev phone, and launch:

cd my-android-project
mvn clean install

The application will be built, then the integration-tests will be built and executed on the Android device.

If you whish to launch just the application:

cd my-android-project
mvn clean install android:deploy android:run

By default the app is built in "debug mode". This means BuildCongif.DEBUG is true and android:debuggable="true" and the apk is signed with the debug key (~/.android/debug.keystore).

When you release your application, it will generate a signed, zipaligned and ProGuard-processed apk. You will have to add a profile to your ~/.m2/settings.xml file containing the signing informations:

<profile>
  <id>android-release</id>
  <properties>
    <sign.keystore>/path/to/keystore</sign.keystore>
    <sign.alias>key alias</sign.alias>
    <sign.storepass>keystore password</sign.storepass>
    <sign.keypass>key password</sign.keypass>
  </properties>
</profile>

At this point you can generate a signed apk using the Maven release plugin:

mvn release:prepare
mvn release:perform -DreleaseProfiles=android-release,release
mvn release:clean

Or, if you wish to generate a signed apk without performing the whole release process:

mvn clean deploy -Pandroid-release,release

Be aware that Android cannot re-deploy artifacts using a different key, so be sure to undeploy all artifacts before running the release.

The android-gcm-quickstart archetype

The android-gcm-quickstart creates a simple Google Cloud Messaging application.

mvn archetype:generate \
  -DarchetypeArtifactId=android-gcm-quickstart \
  -DarchetypeGroupId=de.akquinet.android.archetypes \
  -DarchetypeVersion=1.0.11 \
  -DgroupId=your.company \
  -DartifactId=my-android-application
  -DsenderId=my-sender-id

The 'senderId' value is found in the Google APIs console. You can also set one optional property :

  • The URL of your GCM server, with -DgcmReceiverUrl=http://my-gcm-server. By default it uses the local test server provided by the gcmutils-maven-plugin.

Generated files includes the assets/gcmutils.properties configuration file, containing GCM specific values. Once generated, the library is ready to be built with:

cd my-android-application
mvn clean install

Before starting the test server add the API Key configuration. This can be added in the user settings file, ~/.m2/settings.xml, by system property -DapiKey= or in the pom.xml (not recommended). When the key is added, you can start the GCM test server:

mvn gcmutils:run-server

optionally:

mvn gcmutils:run-server -DapiKey=my-api-key

By default the server is available at http://localhost:9595

The gcmutils-maven-plugin provides three additional configuration options:

  • apiKey - Must be included, but is not recommended to be added in pom.xml
  • port - The port number of the test server. Default: 9595
  • contextRoot - The context root of the test server. Default: "/"

Detailed information on the gcmutils-maven-plugin is available here. For more information on GCM and how to obtain the senderId and API Key, see GCM: Getting Started.

Setting the maven-android-plugin version

You can change the default maven-android-plugin version by specifying the 'android-plugin-version' parameter.

Credits

The android-archetype-project is an open source project licensed under the Apache License 2.0. It is founded by akquinet

Technical Notes

  • As the archetypes used the new archetype format, they don't work with the deprecated goal 'archetype:create'
Comments
  • Add: plugin-version parameter.

    Add: plugin-version parameter.

    Added a plugin-version parameter to the quick start archetype which determines the version of the maven-android-plugin to use.

    This is required because the quick start plugin defaults to 2.8.4, but the m2e-android plugin requires 3.0.0-alpha-2 or greater to work. So, a mechanism to over-ride the default is required.

    opened by rgladwell 12
  • Folder names

    Folder names

    Clemens,

    I am not sure if this will be possible, but here it is anyway. As you are probably aware it is a good practice to have a maven module folder name be the same as the artifactId, however the android artifacts just use hardcoded names like application and application-it ... ideally these folder and module names would match the artifactId of the two artifacts..

    just my 2c

    opened by mosabua 11
  • Proposal: donate project Maven Apache or Codehaus

    Proposal: donate project Maven Apache or Codehaus

    This is probably a bit cheeky, but it would be nice if the android archetypes were automatically available in the M2E Archetype catalogue.

    At the moment M2E users have to manually search for android archetype, entering details such as group and artefact IDs which is fiddly. It would be nice if the android archetypes were already registered with the archetype catalogues.

    As I understand the only way to do this is if the archetypes have org.apache.* or org.codehaus.* artefact IDs. I also understand that to do this, you have to host your project with Apache or Codehaus.

    opened by rgladwell 10
  • Quick start archetype not creating default.properties file

    Quick start archetype not creating default.properties file

    To reproduce follow these steps:

    1. Install m2eclipse plugin a. Install m2eclipse-android-integration b. Install ADT
    2. In Eclipse select File -> New -> Project...
    3. Select Maven -> Maven Project and click "Next"
    4. Click "Next" again
    5. Click "Add Archetype..."
    6. In Archetype Group Id enter "de.akquinet.android.archetypes"
    7. In Archetype Artifact Id" enter "android-quickstart"
    8. In Archetype Version enter "1.0.5-SNAPSHOT"
    9. Click "OK"
      1. Click Next
      2. In "Group Id" enter "com.example"
      3. In "Artifact Id" enter "test-app"
      4. Click Finish

    Expected result: New Android project should be created in Eclipse with expected default.proprties

    Actual result: no default.properties file created, causes build issues with ADT/m2eclipse-android-integration

    opened by rgladwell 10
  • Error using android-quickstart archetype in m2eclipse

    Error using android-quickstart archetype in m2eclipse

    To reproduce follow these steps:

    1. Install m2eclipse plugin
    2. In Eclipse select File -> New -> Project...
    3. Select Maven -> Maven Project and click "Next"
    4. Click "Next" again
    5. Click "Add Archetype..."
    6. In Archetype Group Id enter "de.akquinet.android.archetypes"
    7. In Archetype Artifact Id" enter "android-quickstart"
    8. In Archetype Version enter "1.0.4"
    9. Click "OK"
    10. Click Next
    11. In "Group Id" enter "com.example"
    12. In "Artifact Id" enter "test-app"
    13. Click Finish

    Expected result: New Android project should be created in Eclipse

    Actual result: get error message "Unable to create project from archetype [de.akquinet.android.archetypes:android-quickstart:1.0.4]". See attached Eclipse .log stacktrace

    opened by rgladwell 10
  • Maybe new archetype

    Maybe new archetype

    Not sure if this is in general interest and if you willing to add this to the project, but maybe someone may find it useful.

    I used my previous experiences with this project to create a specific archetype that we started to use in our company Novoda (https://github.com/novoda/android-archetypes). Project is split into four modules:

    • app - android application (depends on core module)
    • core - "plain" Java, stuff that can be easier tested with JUnit and mocked with various frameworks (we try this section to be as much independent from Android, but sometimes some stuff sneak inside)
    • instrumentation - tests for Android stuff in app module
    • team - plain folder with team related stuff if one has to share some documents that may not necessary part of the project, coding standards etc

    Few things to mention:

    • 4.0.1.2 been made default Android version down to number of 4.0 devices and client requirements to build agains this version rather then 2.3 and/or lower
    • By default Android support library, action bar sherlock, robolectric, powermock been added
    • This setup also includes working setup for Emma reports with reports being build also on none rooted devices (Android Maven Plugin wiki info is rather difficult to follow get this setup going http://code.google.com/p/maven-android-plugin/wiki/EmmaMaven)
    • .gitignore for IntelliJ and Eclipse
    opened by peter-budo 7
  • mvn release:prepare fails on fresh project created using the android-release archetype

    mvn release:prepare fails on fresh project created using the android-release archetype

    Repro steps:

    1. Create project using the android-release archetype: mvn archetype:generate -DarchetypeArtifactId=android-release -DarchetypeGroupId=de.akquinet.android.archetypes -DarchetypeVersion=1.0.9 -DgroupId=com.testproject.android -DartifactId=testproject.
    2. Go to created directory: cd testproject.
    3. Attempt to begin generating a signed release build: mvn release:prepare.

    Result: ➜ mvn release:prepare [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: [INFO] [INFO] testproject - Parent [INFO] testproject - Application [INFO] testproject-it - Integration tests [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building testproject - Parent 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-release-plugin:2.1:prepare (default-cli) @ testproject-parent --- [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] testproject - Parent .............................. FAILURE [0.434s] [INFO] testproject - Application ......................... SKIPPED [INFO] testproject-it - Integration tests ................ SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.602s [INFO] Finished at: Fri Apr 19 19:53:32 PDT 2013 [INFO] Final Memory: 8M/81M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.1:prepare (default-cli) on project testproject-parent: Missing required setting: scm connection or developerConnection must be specified. -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

    opened by matthewmichihara 6
  • deleteConflictingFiles

    deleteConflictingFiles

    I'm still sort of newbie in Maven so may request/comment can be silly, but here we go. It is my understanding that android.maven.plugin project with release of 3.0.0-alpha-3 in issue 182 deprecated deleteConflictingFiles parameter. However this still exists in pom when generated with your archetypes. Can you please remove true?

    opened by peter-budo 6
  • Submodule's dir named after artifactId

    Submodule's dir named after artifactId

    Hi there! One more fix, this time for #7 (partially, for android-release only). To make it easier to review, I've made @c3c22d08 as a separate commit because it fixes an indentation only. It may be even thrown away at all.

    opened by manandbytes 5
  • release apk creates an INSTALL_PARSE_FAILED_NO_CERTIFICATES error during installation

    release apk creates an INSTALL_PARSE_FAILED_NO_CERTIFICATES error during installation

    I create a HelloWorld Android projet with the release archetype. I try to generate a release apk and install it on my phone. But, I have the following error with installation step :

    D:\temp\HelloWorldAndroid-parent\HelloWorldAndroid>adb install .\target\HelloWorldAndroid.apk 1880 KB/s (44299 bytes in 0.023s) pkg: /data/local/tmp/HelloWorldAndroid.apk Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]

    I try to compare apk installation with the following case : 1- signed apk generated from eclipse 2- signed apk manually generated with information available on the following page. http://developer.android.com/tools/publishing/app-signing.html

    In the 2 cases, I can install apk with no error.

    I use the following command to generated my release apk with maven : mvn clean install -Prelease.

    Could you help me to solve this problem ?

    Best regards, Franck

    opened by franck-serot 4
  • New android archetype release?

    New android archetype release?

    The tree of the android sdk folders has been slightly changed in the latest versions and also the Maven android plugin etc.When will you release a new release to fix these and other issues?

    Thanks!

    opened by jmdr 4
  • Bump junit from 4.11 to 4.13.1 in /android-archetypes-it

    Bump junit from 4.11 to 4.13.1 in /android-archetypes-it

    Bumps junit from 4.11 to 4.13.1.

    Release notes

    Sourced from junit's releases.

    JUnit 4.13.1

    Please refer to the release notes for details.

    JUnit 4.13

    Please refer to the release notes for details.

    JUnit 4.13 RC 2

    Please refer to the release notes for details.

    JUnit 4.13 RC 1

    Please refer to the release notes for details.

    JUnit 4.13 Beta 3

    Please refer to the release notes for details.

    JUnit 4.13 Beta 2

    Please refer to the release notes for details.

    JUnit 4.13 Beta 1

    Please refer to the release notes for details.

    JUnit 4.12

    Please refer to the release notes for details.

    JUnit 4.12 Beta 3

    Please refer to the release notes for details.

    JUnit 4.12 Beta 2

    No release notes provided.

    JUnit 4.12 Beta 1

    No release notes provided.

    Commits
    • 1b683f4 [maven-release-plugin] prepare release r4.13.1
    • ce6ce3a Draft 4.13.1 release notes
    • c29dd82 Change version to 4.13.1-SNAPSHOT
    • 1d17486 Add a link to assertThrows in exception testing
    • 543905d Use separate line for annotation in Javadoc
    • 510e906 Add sub headlines to class Javadoc
    • 610155b Merge pull request from GHSA-269g-pwp5-87pp
    • b6cfd1e Explicitly wrap float parameter for consistency (#1671)
    • a5d205c Fix GitHub link in FAQ (#1672)
    • 3a5c6b4 Deprecated since jdk9 replacing constructor instance of Double and Float (#1660)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Quickstart archetype has missing or out of date plugin versions

    Quickstart archetype has missing or out of date plugin versions

    The quickstart archetype didn't define a platform.version environment variable (my pom.xml had <platform.version></platform.version>) and had an android.plugin.version of 3.6.0 (current is 3.8.2).

    opened by hborders 1
  • License for generated projects

    License for generated projects

    Can you add info regarding the copyright for the projects generated using these archetypes? ( i.e. disclaim any copyright over the generated project and state the copyright is owned by whoever generated them? ) thanks.

    opened by yogurtearl 5
  • "Integration tests" module should be ignored in release profile

    I create a projet with release archetype. According to a comment extracted from parent pom.xml, "the release profile does sign, proguard, zipalign ... but does not run instrumentation tests". But, if I launch the following command then the instrumentation tests is run.

    cd HelloWorldAndroid-parent mvn clean install -Prelease

    Except I'm mistaken, the "HelloWorldAndroid-it - Integration tests" module should be ignored.

    Could you please help to solve this problem ?

    Best regards, Franck

    opened by franck-serot 5
Maven Plugin for Android Application development and more

ANDROID MAVEN PLUGIN A plugin for Android application development with Apache Maven 3.0.5+ and the Android SDK. Please check out our website for furth

simpligility 1k Jan 4, 2023
Android for Maven Eclipse

#Android for Maven Eclipse Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ricardo Gladwell, Hugo Josefson, Anthony Dannane, Mykola Nikishov, R

Ricardo Gladwell 338 Nov 25, 2022
A plugin for Android Studio and Intellij IDEA that speeds up your day to day android development.

ADB Idea A plugin for Android Studio and Intellij IDEA that speeds up your day to day android development. The following commands are provided: Uninst

Philippe Breault 2k Dec 28, 2022
Vim plugin to do android development.

vim-android Develop for Android using vim. Overview There are three vim scripts that are included in this setup. Those scripts are: SuperTab GitHub Vi

Brandon Powell 178 Dec 23, 2022
A plugin for Android Studio that speeds up your day-to-day flutter development.

Flutter-Toolkit 中文文档 A plugin for Android Studio that speeds up your day-to-day flutter development. Flutter ToolKit(Flutter Build Runner Helper), to

苏晟 4 Oct 19, 2022
A playground to development intellij plugin

pluginExporlor Template ToDo list Create a new IntelliJ Platform Plugin Template project. Get familiar with the template documentation. Verify the plu

Woody Hu 0 Nov 23, 2021
Development environment for methodic projects

Methodic Super Project Get started developing faster! This superproject helps you get started building on the Methodic platform by providing a single

null 1 Mar 24, 2022
IntelliJ / Android Studio plugin for Android Holo Colors

This project is not maintained anymore. Holo Colors doesn't make sense since the introduction of Material Design and the ability to set the primary co

Jérôme Van Der Linden 644 Nov 10, 2022
gradle-android-scala-plugin adds scala language support to official gradle android plugin

gradle-android-scala-plugin gradle-android-scala-plugin adds scala language support to official gradle android plugin. See also sample projects at htt

saturday06 345 Dec 10, 2022
[Deprecated] Android Studio IDE support for Android gradle unit tests. Prepared for Robolectric.

#[Deprecated] Google has finally released a proper solution for unit testing. Therefore this plugin will no longer be activlty maintained. android-stu

Evan Tatarka 236 Dec 30, 2022
ADB WIFI Android Studio plugin for debug android app over Wi-Fi.

ADB WIFI ADB WIFI Android Studio plugin for debug android app over Wi-Fi. How to install in Android Studio: go to Preferences

Sutachad Wichai 298 Jan 3, 2023
Android Studio plug-in for generating ButterKnife injections from selected layout XML.

ButterKnifeZelezny Simple plug-in for Android Studio/IDEA that allows one-click creation of Butterknife view injections. How to install in Android Stu

Avast 3.4k Dec 14, 2022
GPP is Android's unofficial release automation Gradle Plugin. It can do anything from building, uploading, and then promoting your App Bundle or APK to publishing app listings and other metadata.

Gradle Play Publisher Gradle Play Publisher is Android's unofficial release automation Gradle Plugin. It can do anything from building, uploading, and

null 3.9k Dec 30, 2022
IntelliJ Plugin for Android Parcelable boilerplate code generation.

IntelliJ/Android Studio Plugin for Android Parcelable boilerplate code generation This tool generates an Android Parcelable implementation based on fi

Michał Charmas 2.1k Dec 27, 2022
Android Studio plugin which automatically generates drawable selectors from appropriately named resources.

SelectorChapek for Android This Android Studio plugin automatically generates drawable selectors from appropriately named Android resources. How to in

Inmite s.r.o. 1.6k Dec 29, 2022
Gradle plugin which downloads and manages your Android SDK.

DEPRECATED This plugin is deprecated and is no longer being developed. Tools and dependencies are automatically downloaded using version 2.2.0 of the

Jake Wharton 1.4k Dec 29, 2022
A Gradle plugin to support the Groovy language for building Android apps

Groovy language support for Android Deprecated: This plugin has been deprecated in favor of Kotlin which has the full support of JetBrains and Google.

Groovy programming language 853 Dec 21, 2022
Add a different ribbon to each of your Android app variants using this gradle plugin. Of course, configure it as you will

Easylauncher gradle plugin for Android Modify the launcher icon of each of your app-variants using simple gradle rules. Add ribbons of any color, over

Mikel 960 Dec 18, 2022