Last Updated: February 25, 2016
·
650
· erdk

Android, Maven and Deploying

When you build and deploy to device your Android app sometimes you just want to ,,upgrade'' instead of reinstall (because of databases, saved preferences etc.). You could achive this in two simple steps:

  1. Add to your pom.xml ,,maven-compiler-plugin'':

    <plugin>
        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
        <artifactId>android-maven-plugin</artifactId>
        <version>3.4.0</version>
        <configuration>
            ...
            <aaptExtraArgs>
                <aaptExtraArg>-u</aaptExtraArg>
            </aaptExtraArgs>
        </configuration>
        ...
    </plugin>
  2. Run: mvn clean install android:deploy Now your app should be upgraded everytime you deploy instead of remove-install.