Environment requirements and configurations
The Android Link SDK from IoT Platform lets you build a bidirectional data tunnel between your device and IoT Platform. This topic describes the project configuration required to use the Android Link SDK.
Configure the SDK
Add the Alibaba Cloud repository address to the root configuration file (
build.gradleorsettings.gradle) of your Android project.maven { url "https://maven.aliyun.com/nexus/content/repositories/releases/" }In the
./build.gradlefile of the relevant module, such as the App module, add the SDK dependency.NoteTo upgrade from an older version of the SDK, you must first delete the following coordinates from the
.gradlefile:com.aliyun.alink.linksdk:iot-linkkitcom.aliyun.alink.linksdk:iot-device-managercom.aliyun.alink.linksdk:public-channel-core
implementation ('com.aliyun.alink.linksdk:lp-iot-linkkit:1.7.3.8')
AndroidX feature support
For projects that support AndroidX, add the following configuration to the gradle.properties file. A project supports AndroidX if the module's build.gradle file contains the androidx keyword.
android.enableJetifier=trueRelated API
For the Android Link SDK API reference, see LinkKit API.
Get the demo
You can download the Android Link SDK Demo from IoT Platform to quickly connect your Android-based devices to IoT Platform.
By downloading this demo, you agree to the Software License Agreement.
Obfuscation configurations
Add the obfuscation configuration to the ./Demo/app/proguard-rules.pro file in the root directory of your Android project.
# 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.**{*;}