Adding the Thing-IF SDK

We will set up the Android Studio to make it ready for using the Thing-IF.

Adding the SDKs

We need to add two Kii libraries (Kii Cloud SDK and Thing-IF SDK) into your project.

You can download both SDKs from the Maven repository using Gradle. You will be able to download and integrate the SDKs automatically.

You can also download the AAR package files manually from the developer portal. Since the Thing-IF SDK is an open source project, you can also download the source code and build it by yourself.

Add the following dependencies in the "build.gradle" file that locates under the target module to build. The file should be under the "app" directory by default. The configuration to be added depends on the version of your Android Studio.

  • dependencies {
      implementation ('com.kii:thing-if-sdk:0.13.0'){
        transitive=true
      }
      implementation ('com.kii:cloud-sdk:XX.YY.ZZ'){
        transitive=true
      }
    }
  • dependencies {
      compile ('com.kii:thing-if-sdk:0.13.0'){
        transitive=true
      }
      compile ('com.kii:cloud-sdk:XX.YY.ZZ'){
        transitive=true
      }
    }

Specify the version numbers of the two libraries as below.

  • thing-if-sdk

    Specify a version number that is lower than 1.0.0 for the Thing-IF SDK. The latest version is 0.13.0. You cannot specify Version 1.0.0 or later because Version 1.0.0 or later is designed for specific solutions and its specification is out of the scope of this documentation. If you directly reference the source code, specify a version number that is lower than 1.0.0 with the tagging feature of GitHub as below.

    https://github.com/KiiPlatform/thing-if-AndroidSDK/tree/v0.13.0

    Use com.kii:thing-if-sdk:XX.YY.ZZ:library@aar instead of com.kii:thing-if-sdk:XX.YY.ZZ for Version 0.11.1 or earlier. If you upgrade the SDK from Version 0.11.1 or earlier to Version 0.12.0 or later, use com.kii:thing-if-sdk:XX.YY.ZZ. You cannot use the previous syntax when you add Version 0.12.0 or later.

  • cloud-sdk

    Please set XX.YY.ZZ to the latest version you can find by clicking the "Download" link in the developer portal.

    The syntax for Version 2.4.11 or earlier is different from the above. See Adding the Kii Cloud SDK for more information.

Configuring your project

Follow the steps below to configure your project:

  1. Sync your project.

    The "Sync Now" link will be displayed if the project needs to be synchronized. Click the link to do so and then build the mobile app.

    Now the Kii SDK symbols will be complemented.

  2. Update the "AndroidManifest.xml" file to add the necessary permissions.

    Add the following permission under the manifest.

    <uses-permission android:name="android.permission.INTERNET" />
    

    Add either of the following permissions if your mobile app uploads/downloads files as object bodies and those files require access permissions. For the details on the READ_EXTERNAL_STORAGE/ WRITE_EXTERNAL_STORAGE permissions, please refer to the Android Reference.

    Add the permission below if only read access is required:

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    

    Add the permission below if both read and write access is required:

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    

    Also, specify the application class name in the name attribute of the application element. The application class is the class that will be executed before the activity initialization, and this is where we want to initialize the SDK. In this example, we are setting the name as MobileApp.

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        android:name=".MobileApp" >
    

    The AndroidManifest.xml should now look like this:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.myapp" >
    
        <uses-permission android:name="android.permission.INTERNET" />
    
        <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme"
            android:name=".MobileApp" >
         ...
    
  3. Add the MobileApp class that extends the Android Application class.

    You will use the added MobileApp class in Initializing and Onboarding. Add the empty class now to resolve an error in the AndroidManifest.xml file.

    // The MobileApp class should be declared in your mobile app's AndroidManifest.xml.
    public class MobileApp extends Application {
      @Override
      public void onCreate() {
        super.onCreate();
      }
    }
    

Setting Proguard

All the necessary settings for obfuscating the Kii Cloud SDK with Proguard are included in the SDK's AAR file, so you don't need to make any configuration for the obfuscation.