0

We've been trying to use the Azure IoT SDK for Java on Android (via Kotlin) to initiate blob file uploads. The process seems to hang after the SAS token is received and the call to the CloudBlockBlob constructor is made.

So I tried calling the constructor directly and discovered a dependency on javax.xml.stream.XMLOutputFactory by virtue of the dependency on the Azure Storage SDK v. 2.2 (suprisingly old!). The javax libraries AFAIK aren't easily incorporated on Android.

There is a separate Android storage SDK (which presumably doesn't have these dependencies), but including that in addition to the IoT SDK understandably results in a ton of Duplicate Class errors.

What's the way out of this? Fork the Azure IoT SDK for Java and replace the storage SDK reference with the Android version?

Jim O'Neil
  • 23,344
  • 7
  • 42
  • 67

3 Answers3

0

I haven't tried azure IOT yet but I have read about their announcement that the SDK supports android now. They even have a sample and also, a really well written quick start. For installation, they even have the instructions on their github.

Jian Astrero
  • 744
  • 6
  • 19
0

You can use the REST API calls for uploading blob file with the Azure IoT Hub support. There are 3 steps, see my answer here.

Roman Kiss
  • 7,925
  • 1
  • 8
  • 21
  • yes completely ditching the IoT SDK for REST is an option, just not an attractive one. Forego the (presumable) resiliancy of the SDK and roll my own versus adapt the IoT SDK to use the Azure Android Storage SDK . – Jim O'Neil Apr 25 '19 at 12:17
0

In the build.gradle in the app, please declare dependencies as follows to replace the azure-storage with azure-storage-android:

implementation ('com.microsoft.azure.sdk.iot:iot-device-client:1.14.2'){
    exclude module: 'azure-storage'
}
implementation ('com.microsoft.azure.android:azure-storage-android:2.0.0@aar')
implementation ('org.apache.commons:commons-lang3:3.6') 

This is documented in our sample: https://github.com/Azure-Samples/azure-iot-samples-java/edit/master/iot-hub/Samples/device/AndroidSample/app/build.gradle

Let us know if you run into more issues by filing a GitHub issue here.

Yi Zhong - MSFT
  • 306
  • 2
  • 7