-
Notifications
You must be signed in to change notification settings - Fork 2k
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.
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.
- Upgrade the Gradle build tooling in the root
build.gradle
file, as demonstrated here. - In the Android application module, edit the
build.gradle
file as such (refer to this):- Set the
compileSdkVersion
to 29. - Set the
buildToolsVersion
to 29.0.2. - Set the
minSdkVersion
to 21. - Set the 'targetSdkVersion` to 29.
- Set
multiDexEnabled
to true. - Set
buildTypes
to haveminifyEnabled
set to true andshrinkResources
set to true. - Set
compileOptions
to havesourceCompatibility
andtargetCompatibility
to beJavaVersion.VERSION_1_8
. - Set
coreLibraryDesugaringEnabled
to true. - Include the
coreLibraryDesugaring
library shown here. - Include the
multidex
dependency shown here.
- Set the
- Include the Java client libraries that are desired for the application, such as the appconfiguration dependency shown here.
- Exclude the azure-core-http-netty transitive dependency, as shown here.
- Include the azure-core-http-okhttp dependency as the HTTP client, as well as the stax-api and conscrypt-android dependencies.
- Frequently Asked Questions
- Azure Identity Examples
- Configuration
- Performance Tuning
- Android Support
- Unit Testing
- Test Proxy Migration
- Azure Json Migration
- New Checkstyle and Spotbugs pattern migration
- Protocol Methods
- TypeSpec-Java Quickstart
- Getting Started Guidance
- Adding a Module
- Building
- Writing Performance Tests
- Working with AutoRest
- Deprecation
- BOM guidelines
- Release process
- Access helpers