What you will learn

This tutorial will teach you how to configure your obfuscation file to work with the Connecthings SDK.

Step 1: Configure the proguard.cfg file

  • add a proguard.cfg file at the root of your project (or a adtag_progard.cfg)
  • add the following configuration to the file
\#******************* GSON *****************************
\# Gson uses generic type information stored in a class file when working with fields. Proguard
\# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

\# To use GSON @Expose annotation - Should have been set already
-keepattributes *Annotation*

\# Gson specific classes
-keep class sun.misc.Unsafe { *; }
\#-keep class com.google.gson.stream.** { *; }

\#***************** ADTAG SDK ****************
\# > Library adtag
-keep class android.connecthings.adtag.model.** { *; }

\#Beacon
-keep class android.connecthings.util.adtag.beacon.parser.AppleBeacon { *; }

\#AdtagLogs
-keep class android.connecthings.adtag.analytics.model.** { *; }
-keep class android.connecthings.adtag.analytics.sqlite.** { *; }
-keep class android.connecthings.util.adtag.beacon.** { *; }
-keep class android.connecthings.util.connection.** { *; }
\#ENUM
-keepclassmembers enum android.connecthings.util.**  { *; }

Step2: Configure your build.gradle

You can use the following configuration:

android {
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
            signingConfig signingConfigs.release
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
        }
    }
}

Note:

You cannot use the "android-proguard-optimize.txt" file provided by the Android SDK because some optimizations are not supported by the ALT BEACON Library.