build.gradle file of your project:
buildscript {
repositories {
flatDir { dirs '/usr/local/DexGuard6.0/lib' }
mavenCentral()
}
dependencies {
classpath ':dexguard:'
classpath 'com.android.tools.build:gradle:0.13.0'
}
}
apply plugin: 'dexguard'
android {
.....
buildTypes {
debug {
proguardFile getDefaultDexGuardFile('dexguard-debug.pro')
proguardFile 'dexguard-project.txt'
proguardFile 'proguard-project.txt'
}
release {
proguardFile getDefaultDexGuardFile('dexguard-release.pro')
proguardFile 'dexguard-project.txt'
proguardFile 'proguard-project.txt'
}
}
}
Please make sure the repository path in the build script is set correctly for
your system. The 'dexguard' plugin replaces the
'android' plugin — it's an extension.
The standard Gradle build process will now use DexGuard's Gradle task. You'll
see this in the console output: the line :dexguardRelease in the
console replace all lines :dexRelease,
:packageRelease, and :zipalignRelease.
You'll most comonly apply DexGuard to final application projects. This is the easiest and most effective approach, since it processes the combined code in a single step.
However, you can also apply DexGuard to library projects, if the library aar file or jar file is the final product:
buildscript {
repositories {
flatDir { dirs '/usr/local/DexGuard6.0/lib' }
mavenCentral()
}
dependencies {
classpath ':dexguard:'
classpath 'com.android.tools.build:gradle:0.13.0'
}
}
apply plugin: 'dexguard-library'
android {
.....
buildTypes {
debug {
runProguard false
proguardFile getDefaultDexGuardFile('dexguard-library-debug.pro')
proguardFile 'dexguard-project.txt'
proguardFile 'proguard-project.txt'
}
release {
runProguard true
proguardFile getDefaultDexGuardFile('dexguard-library-release.pro')
proguardFile 'dexguard-project.txt'
proguardFile 'proguard-project.txt'
}
}
}
Note the -library- in the configuration file names.
You should take some care with class encryption, as discussed for the class encryption option. Furthermore, tamper detection is only supported if the final application is also built and packaged using DexGuard.
You can find examples of working projects in the directory samples.
gradle with the usual targets, such
as assemble, build, install, and
connectedInstrumentTest. For instance, to build the release
version of your application and install it on a connected device:
gradle installRelease
To build the release version of a library:
gradle assembleRelease
Debug builds use debug settings, without optimization or obfuscation. Release builds use release settings, with full optimization and obfuscation. Applications can optionally be signed. The entries in application archives are always zip-aligned for efficiency.
gradle with a more verbose log level:
gradle -info .....
signingConfigs container in the
build.gradle file of your project. For example, with hard-coded
values:
android {
.....
signingConfigs {
mySignature {
storeFile file('/home/user/.android/debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
defaultConfig {
signingConfig signingConfigs.mySignature
}
}
build.gradle file. Also make sure that you are
using the right version of Gradle itself. The Android plugin is still
evolving rapidly, so even minor version differences can cause
compatibility problems. You can have a look at the samples for working
build.gradle configurations. Feel free to check with us if
you think the DexGuard plugin is incompatible with a recent Android
plugin.--info, and even more with the option
--debug. You then also see DexGuard's log output, which can
be made more verbose with the DexGuard option -verbose.Please consult the more extensive troubleshooting section if you encounter other issues building or running your application.
build.gradle file of your project.