- Notifications
You must be signed in to change notification settings - Fork 2.1k
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.gradlefile, as demonstrated here. - In the Android application module, edit the
build.gradlefile as such (refer to this):- Set the
compileSdkVersionto 29. - Set the
buildToolsVersionto 29.0.2. - Set the
minSdkVersionto 21. - Set the 'targetSdkVersion` to 29.
- Set
multiDexEnabledto true. - Set
buildTypesto haveminifyEnabledset to true andshrinkResourcesset to true. - Set
compileOptionsto havesourceCompatibilityandtargetCompatibilityto beJavaVersion.VERSION_1_8. - Set
coreLibraryDesugaringEnabledto true. - Include the
coreLibraryDesugaringlibrary shown here. - Include the
multidexdependency 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