This archetype creates a multi-module project containing the Android application including action bar support and a project for testing this application (instrumentation tests) :
-Dversion : the first version number of your Maven project
You can define three optional properties :
-Dpackage : define the package used by the application (default : the given groupId)
-DminSdkVersion : the minimum API Level required for the application to run (default : 10, Android 2.3.3)
-DtargetSdkVersion : the targeted Android platform version to use (default : 19, Android 4.4)
Note : The action bar support use ActionBarSherlock Android library only if the minimum API Level required for the application is prior to API level 11.
cd my-android-application
mvn clean install android:deploy android:run
android-library-quickstart archetype
This archetype creates a simple Android library project ready to be used with another Android project application.
To initiate this Android library project :
-Dversion : the first version number of your Maven project
You can define three optional properties :
-Dpackage : define the package used by the library (default : the given groupId)
-DminSdkVersion : the minimum API Level required for the library (default : 10, Android 2.3.3)
-DtargetSdkVersion : the targeted Android platform version to use (default : 19, Android 4.4)
Once generated, your library is ready to be built :
cd my-android-library
mvn clean install
This generated project use JUnit and Robolectric as default unit test framework.
android-library-project archetype
This archetype creates a multi-module project containing the Android application, an Android library project and a project for testing this application and its library (instrumentation tests).
This archetype may be use to develop a complete Android application using a custom Android library or to develop an Android library with an example application using this library :
cd my-android-library-project
mvn clean install android:deploy android:run
This generated project use JUnit and Robolectric as default unit test framework.
android-google-maps-project archetype
This archetype creates a multi-module project containing the Android application using Google Maps Android library and a project for testing this application (instrumentation tests).
Before starting
The Google Maps Android API v2 is distributed as part of the Google Play services SDK.
So we need to install and configure the Google Play services SDK first.
Android SDK
From Android SDK, install the following packages if needed :
cd maven-android-sdk-deployer/
mvn install -P 2.2
cd extras/google-play-services/
mvn clean install
Eclipse
From Eclipse, import the Google Play services library project into your workspace. Click File > Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it :
References the Google Play services in your app's project only (and not the instrumentation tests project).
See the Referencing a Library Project for Eclipse for more information on how to do this.
Your application is ready to be built. Start an android emulator (use the latest Android platform with Google API) or plug a compatible Android dev phone (USB debugging must be enabled in Developer options settings) and execute the following commands :
cd my-android-application
mvn clean install
To deploy and launch the application with Maven :
mvn clean install android:deploy android:run
To undeploy the application with Maven :
mvn android:undeploy
Perform a release build (signed and zipaligned APK)
android-quickstart, android-simple-project, android-actionbar-project and android-library-project archetypes offers also a release profile to generate a signed and zipaligned APK.
By default the application is built in "debug mode". This means the generated class constant BuildCongig.DEBUG and Android Manifest attribute android:debuggable are set to true.
The APK is signed with the default debug key (~/.android/debug.keystore).
A release type build would be necessary for publication of the application to the Play Store and the necessary steps for it is configured. The following preparation for the execution is necessary :
After this preparation, the release build can be invoked with the following command :
mvn clean install -P release
which will in turn sign and zipalign the APK.
Instead of using a properties file (sign.properties), you may also define a Maven profile. Add a profile to your ~/.m2/settings.xml file containing the signing informations :
请发表评论