bin/install_maven_plugin.shor the Windows script
bin/install_maven_plugin.batThey invoke Maven with the proper settings to copy DexGuard to your local repository cache.
pom.xml file of your project,
typically replacing the Android Maven plugin:
<project>
...
<build>
...
<pluginmanagement>
<plugins>
<plugin>
<groupId>com.saikoa.dexguard.maven</groupId>
<artifactId>dexguard-maven-plugin</artifactId>
<version>5.4.00</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginmanagement>
...
</build>
</project>
You can find a small working project in the directory
samples/Maven.
android:"
namespace in the "dexguard:" namespace (which is short for
"com.saikoa.dexguard.maven:dexguard-maven-plugin:").
The only different goal is dexguard:apk, because it runs
DexGuard, which optimizes, obfuscates, converts, signs, and zipaligns the
code.
The goals android:proguard, android:dex,
and android:zipalign are no longer necessary, so they don't have
aliases.
| Phase | Plugin: | goal |
|---|---|---|
| generate-sources | dexguard: | generate-sources |
| process-resources | resources: | resources |
| compile | compiler: | compile |
| process-test-resources | resources: | testResources |
| test-compile | compiler: | testCompile |
| prepare-package | dexguard: | emma |
| package | dexguard: | apk |
| install | install: | install |
| pre-integration-test | dexguard: | internal-pre-integration-test |
| integration-test | dexguard: | internal-integration-test |
| deploy | deploy: | deploy |
mvn with the usual targets, such as clean and
package. For instance, to build the debug version of your
application:
mvn clean package
The plugin creates debug builds by default. You can create release builds by
adding -Dandroid.release=true on the command line or
<release>true</release> in the
pom.xml file of your project:
mvn -Dandroid.release=true clean package
Debug builds use debug settings, without optimization or obfuscation. Release builds use release settings, with full optimization and obfuscation. The entries in application archives are always zip-aligned for efficiency.
The DexGuard plugin can conveniently sign your applications in one go. You can
specify signing parameters on the command line and in the container
<sign>...</sign> in the
pom.xml file of your project. For instance:
mvn -Dandroid.sign.storepass=android -Dandroid.sign.keypass=android clean package
You can then deploy the application to a connected device with the
deploy or redeploy goals:
mvn dexguard:deploy
You can get help on the plugin with the help goal:
mvn dexguard:help
<configuration>
element in the pom.xml of your project:
<project>
...
<build>
...
<plugins>
<plugin>
<groupId>com.saikoa.dexguard.maven</groupId>
<artifactId>dexguard-maven-plugin</artifactId>
<configuration>
... <!-- parameters go here. -->
</configuration>
</plugin>
</plugins>
</build>
</project>
Note that this configuration is not nested in the
<pluginmanagement> element that was used earlier for
activating the plugin.
Since the goals are the same as for the Android plugin, the parameters are the same too. Some parameters no longer have a meaning and are ignored.
dexguard:apk goal supports the same parameters as
the android:apk goal, plus a few parameters from
the android:dex goal and the android:proguard goal,
for backward compatibility.
<aaptExtraArgs>string[]</aaptExtraArgs>
(-Dandroid.aaptExtraArgs=string[])aapt tool when collecting
resources and assets.<androidManifestFile>file</androidManifestFile>
(default = ${project.basedir}/AndroidManifest.xml)AndroidManifest.xml file.<apk>apk_configuration</apk><debug>boolean</debug>
(-Dandroid.apk.debug=boolean)
(default = false)gdbserver executable is added.<nativeToolchain>string</nativeToolchain>
(-Dandroid.nativeToolchain=string)
(default = arm-linux-androideabi-4.4.3)gdbserver executable to be added to a debugging apk.<metaIncludes>string[]</metaIncludes>
(-Dandroid.apk.metaIncludes=string[])META-INF/ prefix) that
should be added to the apk.<assetsDirectory>directory</assetsDirectory>
(default = ${project.basedir}/assets)<attachJar>boolean</attachJar>
(-Dandroid.attachJar=boolean)
(default = true)<attachSources>boolean</attachSources>
(-Dandroid.attachSources=boolean)
(default = false)<combinedAssets>directory</combinedAssets>
(default = ${project.build.directory}/generated-sources/combined-assets/assets)<configurations>string</configurations>
(-Dandroid.configurations=string)aapt should
include in the apk.<dex>dex_configuration</dex><coreLibrary>boolean</coreLibrary>
(-Dandroid.dex.coreLibrary=boolean)
(default = false)<noLocals>boolean</noLocals>
(-Dandroid.dex.noLocals=boolean)
(default = false)<optimize>boolean</optimize>
(-Dandroid.dex.optimize=boolean)
(default = true)<excludeJarResources>string[]</excludeJarResources><extractDuplicates>boolean</extractDuplicates>
(-Dandroid.extractDuplicates=boolean)
(default = false)<extractedDependenciesAssets>directory</extractedDependenciesAssets>
(default = ${project.build.directory}/generated-sources/extracted-dependencies/assets)<extractedDependenciesDirectory>directory</extractedDependenciesDirectory>
(default = ${project.build.directory}/generated-sources/extracted-dependencies)<extractedDependenciesJavaResources>directory</extractedDependenciesJavaResources>
(default = ${project.build.directory}/generated-sources/extracted-dependencies/src/main/resources)<extractedDependenciesJavaSources>directory</extractedDependenciesJavaSources>
(default = ${project.build.directory}/generated-sources/extracted-dependencies/src/main/java)<extractedDependenciesRes>directory</extractedDependenciesRes>
(default = ${project.build.directory}/generated-sources/extracted-dependencies/res)<generateApk>boolean</generateApk>
(-Dandroid.generateApk=boolean)
(default = true)<nativeLibrariesDependenciesHardwareArchitectureDefault>string</nativeLibrariesDependenciesHardwareArchitectureDefault>
(-Dandroid.nativeLibrariesDependenciesHardwareArchitectureDefault=string)
(default = armeabi)<nativeLibrariesDirectory>directory</nativeLibrariesDirectory>
(-Dandroid.nativeLibrariesDirectory=directory)
(default = ${project.basedir}/libs)<ndkOutputDirectory>directory</ndkOutputDirectory>
(default = ${project.build.directory}/ndk-libs)<proguard>proguard_configuration</proguard><skip>boolean</skip>
(-Dandroid.proguard.skip=boolean)<includeJdkLibs>boolean</includeJdkLibs>
(-Dandroid.proguard.includeJdkLibs=boolean)
(default = false)<filterManifest>boolean</filterManifest>
(-Dandroid.proguard.filterManifest=boolean)
(default = false)<filterMavenDescriptor>boolean</filterMavenDescriptor>
(-Dandroid.proguard.filterMavenDescriptor=boolean)
(default = false)<outputDirectory>directory</outputDirectory>
(-Dandroid.proguard.outputDirectory=directory)
(default = proguard)seeds.txt,
usage.txt, and mapping.txt).<config>file</config>
(-Dandroid.proguard.config=file)<proguardSkip>boolean</proguardSkip>
(-Dandroid.proguard.skip=boolean)<includeJdkLibs>boolean</includeJdkLibs>
(-Dandroid.proguard.includeJdkLibs=boolean)
(default = false)<proguardFilterManifest>boolean</proguardFilterManifest>
(-Dandroid.proguard.filterManifest=boolean)
(default = false)<proguardFilterMavenDescriptor>boolean</proguardFilterMavenDescriptor>
(-Dandroid.proguard.filterMavenDescriptor=boolean)
(default = false)<outputDirectory>directory</outputDirectory>
(-Dandroid.proguard.outputDirectory=directory)
(default = proguard)seeds.txt,
usage.txt, and mapping.txt).<proguardConfig>file</proguardConfig>
(-Dandroid.proguard.config=file)<proguardConfigs>file[]</proguardConfigs>
(-Dandroid.proguard.config=file[])<proguardOptions>string[]</proguardOptions>
(-Dandroid.proguard.options=string[])<proguardConfig>file</proguarCconfig>
(-Dandroid.proguard.config=file)<proguardConfigs>file[]</proguardConfigs>
(-Dandroid.proguard.config=file[])<proguardOptions>string[]</proguardOptions>
(-Dandroid.proguard.options=string[])<dexguardConfig>file</dexguardConfig>
(-Dandroid.dexguard.config=file)
(default = dexguard-project.txt)<dexguardConfigs>file[]</dexguardConfigs>
(-Dandroid.dexguard.configs=file[])<release>boolean</release>
(-Dandroid.release=boolean)
(default = false)<renameInstrumentationTargetPackage>string</renameInstrumentationTargetPackage>
(-Dandroid.renameInstrumentationTargetPackage=string)aapt should let instrumentation components
target.<renameManifestPackage>string</renameManifestPackage>
(-Dandroid.renameManifestPackage=string)aapt should set on the application.<resourceDirectory>directory</resourceDirectory>
(default = ${project.basedir}/res)<resourceOverlayDirectories>directory[]</resourceOverlayDirectories><resourceOverlayDirectory>directory</resourceOverlayDirectory>
(default = ${project.basedir}/res-overlay)<sdk>sdk_configuration</sdk><path>directory</path>
(-Dandroid.sdk.path=directory)
(ANDROID_SDK=directory)<platform>string</platform>
(-Dandroid.sdk.platform=string)<sign>signing_configuration</sign><debug>string</debug>
(-Dandroid.sign.debug=string)
(default = auto)<keystore>file</keystore>
(-Dandroid.sign.keystore=file)<storepass>string</storepass>
(-Dandroid.sign.storepass=string)<alias>string</alias>
(-Dandroid.sign.alias=string)<keypass>string</keypass>
(-Dandroid.sign.keypass=string)<sourceDirectories>directory[]</sourceDirectories>
(-Dandroid.sourceDirectories=directory[])<outputApk>file</outputApk>
(-Dandroid.outputApk=file)
(default = ${project.build.directory}/${project.build.finalName}.apk)-Dandroid.release=true or
<release>true</release>.Please consult the more extensive troubleshooting section if you encounter other issues building or running your application.