SDK Integration in Android Studio

  Step 1: Gradle integration

(You can go through our video tutorial for step 1 from here or continue reading. Please ensure that after this video tutorial, you follow the Step 2 as mentioned in this document.)

a. Gradle file of app module

Make the following entries (marked in red) in the build.gradle of the app module.

apply plugin: 'com.android.application'
apply plugin: 'io.hansel.preprocessor'
android {
    ...
    defaultConfig { ... }
    buildTypes {
        ...
    }
}
repositories {
    maven { url 'http://hansel.io/maven' }
}
buildscript {
    repositories {
       mavenCentral()
       maven { url 'http://hansel.io/maven' }
    }
    dependencies {
        classpath 'io.hansel.preprocessor:preprocessor:5.0.4'
    }
}

 

b. Gradle file of the project

Make sure that the version of android tools is 1.5.0 or above. You can set it in the build.gradle of the project (outermost build.gradle file)

buildscript {
    repositories {
        ….
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
    }
}
allprojects {
   repositories {
	….
   }
}

 

c. Initialize SDK

Add the following lines in <module>/src/main/res/values/strings.xml. Replace <hansel_app_id> and <hansel_app_key> with values you get from the Setting section on the Hansel dashboard. 

<meta-data
 
android:name="HANSEL_APP_ID"

android:value="<hansel_app_id>"/>


<meta-data
android:name="HANSEL_APP_KEY"

android:value="<hansel_app_key>"/>


Add the following line in the onCreate of the Application class. If you don’t have an application class, go through the section "Adding Application Class"

Hansel.init(this); 

 

d. Receive push from Hansel

Please go through the Hansel change push for integration details. If push notifications are not configured, any change you make using Hansel dashboard may not reflect on the device for the next 12 hours.

  

Step 2: Unlock the Hansel dashboard

(You can go through our video for this step over here or continue reading to see how to unlock the Hansel dashboard. Please ensure that after this video tutorial, you follow the Step 3 as mentioned in this document.)

Once the Hansel SDK is successfully integrated in your project, you’ll need to unlock the dashboard. The dashboard can be unlocked by running the app (with Hansel integrated) on a device or emulator. After that, you’ll have to reload the dashboard.

 

Step 3: Configure app on dashboard

Upload GCM key

Please check this document for details.

Uploading Hansel-Crumb/Archive

(You can also check out the video over here to see how to upload the crumb file.)

Once you’ve successfully compiled the project, Hansel Crumb file will get generated. You can find the file location printed in the gradle console. It’ll be similar to the sample output below. Upload the hansel_crumb.zip file in the settings section of the app on the dashboard. You’ll have to choose the correct app version before uploading. If you don’t see the app version in the settings section, you’ll need to run the app on a device or emulator and reload the dashboard.

**************************************Hansel Output**************************************

Hansel archive generated at: /Users/blah/blash/project/app/build/tmp/hansel/hansel_crumb.zip

**************************************/Hansel Output**************************************
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.