Skip to content

Android Support

Jonathan Giles edited this page Jan 14, 2020 · 1 revision

The Azure SDK for Java is primarily targeted for use in non-Android environments, however it has been shown to work on Android devices. Because of the dependencies used by the Azure SDK for Java, by default the client libraries have an Android baseline of API level 26. What is presented below is a short tutorial on the steps required to desugar a Java client library such that it can work on Android API level 21 and later. There is a sample application available on GitHub that can be used to get started quickly.

Steps to desugar down to API level 21

The following steps assume an existing Android application with a Gradle build already setup. They also assume Android Studio 4.0 or later is available and being used.

  1. Upgrade the Gradle build tooling in the root build.gradle file, as demonstrated here.
  2. In the Android application module, edit the build.gradle file as such (refer to this):
    1. Set the compileSdkVersion to 29.
    2. Set the buildToolsVersion to 29.0.2.
    3. Set the minSdkVersion to 21.
    4. Set the 'targetSdkVersion` to 29.
    5. Set multiDexEnabled to true.
    6. Set buildTypes to have minifyEnabled set to true and shrinkResources set to true.
    7. Set compileOptions to have sourceCompatibility and targetCompatibility to be JavaVersion.VERSION_1_8.
    8. Set coreLibraryDesugaringEnabled to true.
    9. Include the coreLibraryDesugaring library shown here.
    10. Include the multidex dependency shown here.
  3. Include the Java client libraries that are desired for the application, such as the appconfiguration dependency shown here.
    1. Exclude the azure-core-http-netty transitive dependency, as shown here.
    2. Include the azure-core-http-okhttp dependency as the HTTP client, as well as the stax-api and conscrypt-android dependencies.
Clone this wiki locally