1# AWS CRT Android 2 3This document provides information about building and using the AWS CRT Java with Android. 4 5If you have any issues or feature requests, please file an issue or pull request. 6 7API documentation: https://awslabs.github.io/aws-crt-java/ 8 9This SDK is built on the AWS Common Runtime, a collection of libraries 10([aws-c-common](https://github.com/awslabs/aws-c-common), 11[aws-c-io](https://github.com/awslabs/aws-c-io), 12[aws-c-mqtt](https://github.com/awslabs/aws-c-mqtt), 13[aws-c-http](https://github.com/awslabs/aws-c-http), 14[aws-c-cal](https://github.com/awslabs/aws-c-cal), 15[aws-c-auth](https://github.com/awslabs/aws-c-auth), 16[s2n](https://github.com/awslabs/s2n)...) written in C to be 17cross-platform, high-performance, secure, and reliable. 18 19*__Jump To:__* 20 21* [Installation](#installation) 22 * [Minimum requirements](#minimum-requirements) 23 * [Build and install CRT from source](#build-and-install-crt-from-source) 24* [Consuming AWS CRT Android](#consuming-aws-crt-android) 25 * [Consuming from Maven](#consuming-from-maven) 26 * [Consuming from locally installed](#consuming-from-locally-installed) 27 28## Installation 29 30### Minimum requirements 31* Java 11+ ([Download and Install Java](https://www.java.com/en/download/help/download_options.html)) 32 * [Set JAVA_HOME](#set-java_home) 33* Gradle 7.4.2 ([Download and Install Gradle](https://gradle.org/install/)) 34* Android SDK 24 ([Doanload SDK Manager](https://developer.android.com/tools/releases/platform-tools#downloads)) 35 * [Set ANDROID_HOME](#set-android_home) 36* Android NDK ([Download and install Android NDK](https://developer.android.com/ndk/downloads)) 37 38### Build and install CRT from source 39Supports API 24 or newer. 40 41``` sh 42# Create a workspace directory to hold all the SDK files 43mkdir sdk-workspace 44cd sdk-workspace 45# Clone the CRT repository 46# (Use the latest version of the CRT here instead of "v0.27.6) 47git clone --branch v0.27.6 --recurse-submodules https://github.com/awslabs/aws-crt-java.git 48# Compile and install the CRT for Android 49./gradlew :android:crt:build 50# Install CRT locally 51./gradlew :android:crt:publishToMavenLocal 52``` 53 54## Consuming AWS CRT Android 55 56### Consuming from Maven 57Consuming this CRT via Maven is the preferred method of consuming it and using it within your application. To consume 58AWS CRT Android in your application, add the following to your `build.gradle` repositories and dependencies: 59 60``` groovy 61repositories { 62 mavenCentral() 63} 64 65dependencies { 66 api 'software.amazon.awssdk.crt:aws-crt-android:0.27.6' 67} 68``` 69Replace `0.27.6` in `software.amazon.awssdk.crt:aws-crt-android:0.27.6` with the latest release version of the CRT library. 70Look up the latest SDK version here: https://github.com/awslabs/aws-crt-java/releases 71 72### Consuming from locally installed 73You may also consume AWS CRT Android in your application using a locally installed version by adding the 74following to your `build.gradle` repositories and depenencies: 75``` groovy 76repositories { 77 mavenLocal() 78} 79 80dependencies { 81 api 'software.amazon.awssdk.crt:aws-crt-android:0.27.6' 82} 83``` 84Replace `0.27.6` in `software.amazon.awssdk.crt:aws-crt-android:0.27.6` with the latest release version for the SDK 85or replace with `1.0.0-SNAPSHOT` to use the CRT built and installed from source. 86 87 88## Set JAVA_HOME 89 90Below are instructions on how you can set `JAVA_HOME`, which varies from depending on whether you are on Windows or are on MacOS/Linux: 91 92### Windows 931. Open "Edit the system environment variable" 942. Click "New" to create new environment variable 95 - variable name: `JAVA_HOME` 96 - variable value: `<jdk_install_path>` (example: `C:\Program Files\Java\jdk-17.0.2`) 973. Press "Ok" to save the changes 984. re-open the command prompt for the environment variables to apply 99 100### MacOS and Linux 101Run the following command to set the JAVA_PATH 102``` sh 103# (example: "/Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home") 104export JAVA_HOME=<jdk_install_path> 105``` 106 107## Set ANDROID_HOME 108Below are instructions on how you can set `ANDROID_HOME`, which varies from depending on whether you are on Windows or are on MacOS/Linux: 109 110### Windows 1111. Open "Edit the system environment variable" 1122. Click "New" to create new environment variable 113 - variable name: `ANDROID_HOME` 114 - variable value: `<android_sdk_path>` (example: `C:\Users\YourUsername\AppData\Local\Android\Sdk`) 1153. Press "Ok" to save the changes 1164. re-open the command prompt for the environment variables to apply 117 118### MacOS and Linux 119Run the following command to set the JAVA_PATH 120``` sh 121# (example: "/Users/YourUsername/Library/Android/sdk") 122export ANDROID_HOME=<android_sdk_path> 123```