All Products
Search
Document Center

IoT Platform:Environment requirements and configuration

Last Updated:Feb 28, 2024

You can use Link SDK for Android of IoT Platform to build a two-way data tunnel between your device and IoT Platform. This topic describes how to configure an Android project to use Link SDK for Android.

Configure Link SDK for Android

  1. Add the address of the Alibaba Cloud repository to the build.gradle or settings.gradle file in the root directory of the Android project.

    maven {
        url "https://maven.aliyun.com/nexus/content/repositories/releases/"
    }         
  2. Add dependencies to the ./build.gradle file of the related module, such as app, and download Link SDK for Android.

    implementation ('com.aliyun.alink.linksdk:lp-iot-linkkit:1.7.3.8') 

AndroidX features

If you create a project that supports AndroidX features, the keyword androidx is included in the build.gradle file of the related module. In this case, specify the following code in the gradle.properties file:

android.enableJetifier=true

API operations

For information about API operations in Link SDK for Android, see LinkKit API.

Obtain a demo

You can download a demo that is provided by IoT Platform and use the demo to connect a device that runs Android to IoT Platform. Download link: Android Link SDK Demo.

Important

By downloading the demo, you agree to the software license agreement.

Configure obfuscation

In the ./Demo/app/proguard-rules.pro file in the root directory of the Android project, complete the obfuscation configuration.

# linkkit API
-keep class com.aliyun.alink.**{*;}
-keep class com.aliyun.linksdk.**{*;}
-dontwarn com.aliyun.**
-dontwarn com.alibaba.**
-dontwarn com.alipay.**
-dontwarn com.ut.**

# keep native method
-keepclasseswithmembernames class * {
    native <methods>;
}

# keep netty
-keepattributes Signature,InnerClasses
-keepclasseswithmembers class io.netty.** {
    *;
}
-keepnames class io.netty.** {
    *;
}
-dontwarn io.netty.**
-dontwarn sun.**

# keep mqtt
-keep public class org.eclipse.paho.**{*;}

# keep fastjson
-dontwarn com.alibaba.fastjson.**
-keep class com.alibaba.fastjson.**{*;}

# keep gson
-keep class com.google.gson.** { *;}

# keep network core
-keep class com.http.**{*;}
-keep class org.mozilla.**{*;}

# keep okhttp
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn javax.annotation.**
-dontwarn org.mozilla.**

-keep class okio.**{*;}
-keep class okhttp3.**{*;}
-keep class org.apache.commons.codec.**{*;}

-keep class com.aliyun.alink.devicesdk.demo.FileProvider{*;}
-keep class android.support.**{*;}
-keep class android.os.**{*;}