This projects provides several Maven archetypes for Android. Those archetypes allows to quickly bootstrap a Maven project
to develop an android application.
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:
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).
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:
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.
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:
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:
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'
请发表评论