Proguard Settings
Proguard is a code optimization and obfuscation tool that reduces app size and enhances security for Android release builds. This guide provides the necessary Proguard rules to ensure the AppTrove Expo SDK functions correctly while maintaining security and performance.
Purpose
Proguard settings are essential for:
- Code Optimization: Reduces app size by removing unused code
- Security Enhancement: Obfuscates code to prevent reverse engineering
- Performance: Improves app performance through code optimization
- SDK Compatibility: Ensures the AppTrove SDK functions correctly in release builds
Proguard Configuration
Step 1: Locate Proguard Configuration File
The Proguard configuration file is typically located at:
android/app/proguard-rules.pro
(for most projects)android/app/build.gradle
(if rules are defined inline)
Step 2: Add Proguard Rules
Add the following rules to your Proguard configuration file:
-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 3: Enable Proguard in Build Configuration
Ensure Proguard is enabled in your android/app/build.gradle
file:
android {
// ... other configurations
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
Testing Proguard Configuration
Step 1: Build Release Version
Build your app in release mode to test Proguard configuration:
cd android
./gradlew assembleRelease
Step 2: Test SDK Functionality
After building, test the following SDK features:
- SDK Initialization: Ensure the SDK initializes without errors
- Event Tracking: Test tracking events in release build
- Deep Linking: Verify deep linking functionality
- Campaign Data: Test campaign data retrieval
Step 3: Check for Issues
Look for these common issues:
- ClassNotFoundException: Missing Proguard rules for required classes
- MethodNotFoundException: Missing rules for specific methods
- Runtime Errors: SDK functionality not working in release build
Troubleshooting
Common Issues
Problem: SDK not working in release build Solution: Check that all required classes are kept in Proguard rules
Problem: Advertising ID not available Solution: Ensure Google Play Services rules are included
Problem: Deep linking not working Solution: Verify that all SDK classes are preserved
Problem: Build errors with Proguard Solution: Check for conflicting rules or missing dependencies
Debug Steps
- Enable Proguard Logging: Add
-printmapping mapping.txt
to see what's being removed - Check Build Logs: Review build output for warnings and errors
- Test Incrementally: Add rules one by one to identify issues
- Verify Dependencies: Ensure all required dependencies are included
Best Practices
- Test Thoroughly: Always test Proguard configuration in release builds
- Keep Rules Minimal: Only keep classes that are actually needed
- Monitor App Size: Check that Proguard is reducing app size as expected
- Update Regularly: Keep Proguard rules updated with SDK updates
- Document Changes: Keep track of any custom Proguard rules you add
Next Steps
After configuring Proguard:
- Test your app in release mode to ensure all features work
- Monitor app size and performance improvements
- For assistance, contact Trackier support at support@trackier.com