Proguard Settings
Choose your SDK version below:
- Apptrove SDK → Recommended for all projects (Latest: v2.x.x)
- Trackier SDK → Will be deprecated in August 2026 (Latest legacy: v1.x.xx)
Use the tabs below for SDK-specific snippets.
Proguard is a tool used in Android release builds to optimize, shrink, and obfuscate code, reducing app size and enhancing security. To ensure the Apptrove Cordova SDK and its dependencies function correctly when Proguard is enabled, specific rules must be added to prevent critical classes and methods from being removed or renamed. This section outlines how to configure Proguard rules for your Cordova-based Android app.
Configure Proguard Rules
To maintain the functionality of the Apptrove SDK and its dependencies in optimized builds, add the required Proguard rules to your project's Proguard configuration file.
Step 1: Add Proguard Rules
- Locate or create the Proguard configuration file in your Android project, typically at
android/app/proguard-rules.pro. - Add the following rules to preserve Apptrove SDK classes and dependencies:
- ✓ Apptrove SDK (Recommended)
- Trackier SDK (Deprecating August 2026)
-keep class com.apptrove.sdk.** { *; }
-keep class com.google.android.gms.common.ConnectionResult {
int SUCCESS;
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
java.lang.String getId();
boolean isLimitAdTrackingEnabled();
}
-keep public class com.android.installreferrer.** { *; }
-keep class kotlin.Metadata { *; }
-keep class kotlin.reflect.jvm.internal.** { *; }
-keep class kotlin.** { *; }
-dontwarn kotlin.**
Trackier SDK will be deprecated in August 2026. Migrate to Apptrove SDK 2.x for ongoing support.
-keep class com.trackier.sdk.** { *; }
-keep class com.google.android.gms.common.ConnectionResult {
int SUCCESS;
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
java.lang.String getId();
boolean isLimitAdTrackingEnabled();
}
-keep public class com.android.installreferrer.** { *; }
-keep class kotlin.Metadata { *; }
-keep class kotlin.reflect.jvm.internal.** { *; }
-keep class kotlin.** { *; }
-dontwarn kotlin.**
Step 2: Enable Proguard in Android Build
- Open the
android/app/build.gradlefile in your Cordova project. - Ensure Proguard is enabled for release builds by verifying or adding the following configuration in the
buildTypessection:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Step 3: Test the Release Build
- Build the Android release APK using the following command in the project root directory:
cd android && ./gradlew assembleRelease
- Install the APK on a device or emulator.
- Test Apptrove SDK features (e.g., event tracking, deep linking) to ensure they function correctly in the optimized build.
Expected Outcome
The Apptrove SDK and its dependencies will remain fully functional in the optimized release build, with no critical classes or methods removed by Proguard. Tracking data will continue to be sent to the Apptrove without issues, verifiable in the Apptrove Panel.
Best Practices
- Test Proguard Rules: Build and test the release APK with Proguard enabled in a development environment to verify SDK functionality before deploying to production.
- Backup Proguard Files: Commit
proguard-rules.proto version control to track changes and ensure consistency across builds. - Monitor Build Logs: Check Android build logs for Proguard-related warnings or errors that may affect the SDK.
- Use Default Proguard Files: Include the default
proguard-android-optimize.txtfile inbuild.gradleto leverage Android's standard optimizations alongside SDK-specific rules. - Validate SDK Functionality: After applying Proguard rules, test key SDK features like event tracking and deep linking to confirm they work as expected.
- Keep Rules Updated: Check the Apptrove Documentation Portal for SDK updates and troubleshooting guidance.
Troubleshooting
- SDK Features Not Working in Release Build:
- Confirm all required Proguard rules are added to
proguard-rules.prowithout modifications. - Check build logs for warnings about missing classes or methods related to
com.trackier.sdk, Google Play Services, or Install Referrer. - Temporarily set
minifyEnabled falseinbuild.gradleto isolate Proguard-related issues.
- Confirm all required Proguard rules are added to
- Build Errors with Proguard:
- Verify the syntax of the Proguard rules in
proguard-rules.profor typos or formatting errors. - Ensure the
proguardFilesline inbuild.gradlecorrectly referencesproguard-rules.pro.
- Verify the syntax of the Proguard rules in
- Tracking Data Not Appearing in Apptrove Panel:
- Test the release APK to ensure the SDK is initialized and tracking events correctly.
- Confirm the app token and environment match the Apptrove Panel configuration.
For further assistance, refer to the Apptrove Documentation Portal or contact Apptrove support at support@apptrove.com.