From 367e4011cabd2a84189d273623ca81ab6ffc2bfa Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Wed, 27 Sep 2023 08:43:02 -0700 Subject: [PATCH 01/12] initial work for separation --- android/settings.gradle | 3 +-- {android => samples/Android}/app/.gitignore | 0 {android => samples/Android}/app/build.gradle | 0 {android => samples/Android}/app/proguard-rules.pro | 0 .../awssdk/iotsamples/ExampleInstrumentedTest.kt | 0 .../Android}/app/src/main/AndroidManifest.xml | 0 .../Android}/app/src/main/assets/.gitignore | 0 .../Android}/app/src/main/assets/README.md | 0 .../amazon/awssdk/iotsamples/MainActivity.kt | 0 .../res/drawable-v24/ic_launcher_foreground.xml | 0 .../main/res/drawable/ic_launcher_background.xml | 0 .../app/src/main/res/layout/activity_main.xml | 0 .../src/main/res/mipmap-anydpi-v26/ic_launcher.xml | 0 .../res/mipmap-anydpi-v26/ic_launcher_round.xml | 0 .../app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../src/main/res/mipmap-hdpi/ic_launcher_round.png | Bin .../app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher_round.png | Bin .../app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher_round.png | Bin .../app/src/main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxhdpi/ic_launcher_round.png | Bin .../app/src/main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxxhdpi/ic_launcher_round.png | Bin .../Android}/app/src/main/res/values/colors.xml | 0 .../Android}/app/src/main/res/values/strings.xml | 0 .../Android}/app/src/main/res/values/styles.xml | 0 .../amazon/awssdk/iotsamples/ExampleUnitTest.kt | 0 28 files changed, 1 insertion(+), 2 deletions(-) rename {android => samples/Android}/app/.gitignore (100%) rename {android => samples/Android}/app/build.gradle (100%) rename {android => samples/Android}/app/proguard-rules.pro (100%) rename {android => samples/Android}/app/src/androidTest/java/software/amazon/awssdk/iotsamples/ExampleInstrumentedTest.kt (100%) rename {android => samples/Android}/app/src/main/AndroidManifest.xml (100%) rename {android => samples/Android}/app/src/main/assets/.gitignore (100%) rename {android => samples/Android}/app/src/main/assets/README.md (100%) rename {android => samples/Android}/app/src/main/java/software/amazon/awssdk/iotsamples/MainActivity.kt (100%) rename {android => samples/Android}/app/src/main/res/drawable-v24/ic_launcher_foreground.xml (100%) rename {android => samples/Android}/app/src/main/res/drawable/ic_launcher_background.xml (100%) rename {android => samples/Android}/app/src/main/res/layout/activity_main.xml (100%) rename {android => samples/Android}/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml (100%) rename {android => samples/Android}/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml (100%) rename {android => samples/Android}/app/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename {android => samples/Android}/app/src/main/res/mipmap-hdpi/ic_launcher_round.png (100%) rename {android => samples/Android}/app/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename {android => samples/Android}/app/src/main/res/mipmap-mdpi/ic_launcher_round.png (100%) rename {android => samples/Android}/app/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename {android => samples/Android}/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png (100%) rename {android => samples/Android}/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename {android => samples/Android}/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png (100%) rename {android => samples/Android}/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename {android => samples/Android}/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png (100%) rename {android => samples/Android}/app/src/main/res/values/colors.xml (100%) rename {android => samples/Android}/app/src/main/res/values/strings.xml (100%) rename {android => samples/Android}/app/src/main/res/values/styles.xml (100%) rename {android => samples/Android}/app/src/test/java/software/amazon/awssdk/iotsamples/ExampleUnitTest.kt (100%) diff --git a/android/settings.gradle b/android/settings.gradle index 1041d10c0..b05db04f6 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,3 +1,2 @@ -rootProject.name='IoTSamples' -include ':app' +rootProject.name='aws-iot-device-sdk-android' include ':iotdevicesdk' diff --git a/android/app/.gitignore b/samples/Android/app/.gitignore similarity index 100% rename from android/app/.gitignore rename to samples/Android/app/.gitignore diff --git a/android/app/build.gradle b/samples/Android/app/build.gradle similarity index 100% rename from android/app/build.gradle rename to samples/Android/app/build.gradle diff --git a/android/app/proguard-rules.pro b/samples/Android/app/proguard-rules.pro similarity index 100% rename from android/app/proguard-rules.pro rename to samples/Android/app/proguard-rules.pro diff --git a/android/app/src/androidTest/java/software/amazon/awssdk/iotsamples/ExampleInstrumentedTest.kt b/samples/Android/app/src/androidTest/java/software/amazon/awssdk/iotsamples/ExampleInstrumentedTest.kt similarity index 100% rename from android/app/src/androidTest/java/software/amazon/awssdk/iotsamples/ExampleInstrumentedTest.kt rename to samples/Android/app/src/androidTest/java/software/amazon/awssdk/iotsamples/ExampleInstrumentedTest.kt diff --git a/android/app/src/main/AndroidManifest.xml b/samples/Android/app/src/main/AndroidManifest.xml similarity index 100% rename from android/app/src/main/AndroidManifest.xml rename to samples/Android/app/src/main/AndroidManifest.xml diff --git a/android/app/src/main/assets/.gitignore b/samples/Android/app/src/main/assets/.gitignore similarity index 100% rename from android/app/src/main/assets/.gitignore rename to samples/Android/app/src/main/assets/.gitignore diff --git a/android/app/src/main/assets/README.md b/samples/Android/app/src/main/assets/README.md similarity index 100% rename from android/app/src/main/assets/README.md rename to samples/Android/app/src/main/assets/README.md diff --git a/android/app/src/main/java/software/amazon/awssdk/iotsamples/MainActivity.kt b/samples/Android/app/src/main/java/software/amazon/awssdk/iotsamples/MainActivity.kt similarity index 100% rename from android/app/src/main/java/software/amazon/awssdk/iotsamples/MainActivity.kt rename to samples/Android/app/src/main/java/software/amazon/awssdk/iotsamples/MainActivity.kt diff --git a/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/samples/Android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml similarity index 100% rename from android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml rename to samples/Android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml diff --git a/android/app/src/main/res/drawable/ic_launcher_background.xml b/samples/Android/app/src/main/res/drawable/ic_launcher_background.xml similarity index 100% rename from android/app/src/main/res/drawable/ic_launcher_background.xml rename to samples/Android/app/src/main/res/drawable/ic_launcher_background.xml diff --git a/android/app/src/main/res/layout/activity_main.xml b/samples/Android/app/src/main/res/layout/activity_main.xml similarity index 100% rename from android/app/src/main/res/layout/activity_main.xml rename to samples/Android/app/src/main/res/layout/activity_main.xml diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/samples/Android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml rename to samples/Android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/samples/Android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml similarity index 100% rename from android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml rename to samples/Android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/samples/Android/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from android/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to samples/Android/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/samples/Android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png similarity index 100% rename from android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png rename to samples/Android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/samples/Android/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from android/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to samples/Android/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/samples/Android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png similarity index 100% rename from android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png rename to samples/Android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/samples/Android/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from android/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to samples/Android/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/samples/Android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png similarity index 100% rename from android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png rename to samples/Android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/samples/Android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to samples/Android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/samples/Android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png similarity index 100% rename from android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png rename to samples/Android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/samples/Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to samples/Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/samples/Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png similarity index 100% rename from android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png rename to samples/Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png diff --git a/android/app/src/main/res/values/colors.xml b/samples/Android/app/src/main/res/values/colors.xml similarity index 100% rename from android/app/src/main/res/values/colors.xml rename to samples/Android/app/src/main/res/values/colors.xml diff --git a/android/app/src/main/res/values/strings.xml b/samples/Android/app/src/main/res/values/strings.xml similarity index 100% rename from android/app/src/main/res/values/strings.xml rename to samples/Android/app/src/main/res/values/strings.xml diff --git a/android/app/src/main/res/values/styles.xml b/samples/Android/app/src/main/res/values/styles.xml similarity index 100% rename from android/app/src/main/res/values/styles.xml rename to samples/Android/app/src/main/res/values/styles.xml diff --git a/android/app/src/test/java/software/amazon/awssdk/iotsamples/ExampleUnitTest.kt b/samples/Android/app/src/test/java/software/amazon/awssdk/iotsamples/ExampleUnitTest.kt similarity index 100% rename from android/app/src/test/java/software/amazon/awssdk/iotsamples/ExampleUnitTest.kt rename to samples/Android/app/src/test/java/software/amazon/awssdk/iotsamples/ExampleUnitTest.kt From e43cf94d886e8c798ec13c02dfa8aa75494163cb Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Wed, 27 Sep 2023 09:33:56 -0700 Subject: [PATCH 02/12] settings.gradle file required --- samples/Android/settings.gradle | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 samples/Android/settings.gradle diff --git a/samples/Android/settings.gradle b/samples/Android/settings.gradle new file mode 100644 index 000000000..6c89b811d --- /dev/null +++ b/samples/Android/settings.gradle @@ -0,0 +1,3 @@ +/* + * Necessary gradle file for the sample + */ \ No newline at end of file From d2eda5b198072abdea60e6c153e955669b2c6892 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Wed, 27 Sep 2023 10:46:32 -0700 Subject: [PATCH 03/12] sample app update --- samples/Android/app/.gitignore | 2 ++ samples/Android/app/build.gradle | 35 ++++++++++++++++++++++---------- samples/Android/settings.gradle | 3 --- 3 files changed, 26 insertions(+), 14 deletions(-) delete mode 100644 samples/Android/settings.gradle diff --git a/samples/Android/app/.gitignore b/samples/Android/app/.gitignore index 796b96d1c..faccdaf50 100644 --- a/samples/Android/app/.gitignore +++ b/samples/Android/app/.gitignore @@ -1 +1,3 @@ /build +./gradle +/local.properties \ No newline at end of file diff --git a/samples/Android/app/build.gradle b/samples/Android/app/build.gradle index 3c996e8e7..179302846 100644 --- a/samples/Android/app/build.gradle +++ b/samples/Android/app/build.gradle @@ -1,3 +1,21 @@ +buildscript { + ext.kotlin_version = '1.5.0' + repositories { + google() + mavenCentral() + } + dependencies { + classpath "com.android.tools.build:gradle:7.1.2" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +repositories { + google() + mavenLocal() + mavenCentral() +} + apply plugin: 'com.android.application' apply plugin: 'kotlin-android' @@ -18,11 +36,11 @@ android { sourceSets { main { - java.srcDir '../../samples/Utils/CommandLineUtils' - java.srcDir '../../samples/BasicPubSub/src/main/java' - java.srcDir '../../samples/Jobs/src/main/java' - java.srcDir '../../samples/Shadow/src/main/java' - java.srcDir '../../samples/CognitoConnect/src/main/java' + java.srcDir '../..Utils/CommandLineUtils' + java.srcDir '../..BasicPubSub/src/main/java' + java.srcDir '../..Jobs/src/main/java' + java.srcDir '../..Shadow/src/main/java' + java.srcDir '../..CognitoConnect/src/main/java' java.srcDir 'src/main/java' } } @@ -40,14 +58,9 @@ android { ndkVersion '23.1.7779620' } -repositories { - mavenLocal() - mavenCentral() -} - dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation project(":iotdevicesdk") + api 'software.amazon.awssdk.iotdevicesdk:aws-iot-device-sdk-android:1.17.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.core:core:1.2.0' diff --git a/samples/Android/settings.gradle b/samples/Android/settings.gradle deleted file mode 100644 index 6c89b811d..000000000 --- a/samples/Android/settings.gradle +++ /dev/null @@ -1,3 +0,0 @@ -/* - * Necessary gradle file for the sample - */ \ No newline at end of file From b29f0eb0703d2b6c85058f822b3c7058a7e3d3b1 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Wed, 27 Sep 2023 14:50:41 -0700 Subject: [PATCH 04/12] documentation --- README.md | 46 +----------------- documents/ANDROID.md | 95 ++++++++++++++++++++++++++++++++++++++ documents/PREREQUISITES.md | 17 +++++++ samples/Android/README.md | 79 +++++++++++++++++++++++++++++++ 4 files changed, 192 insertions(+), 45 deletions(-) create mode 100644 documents/ANDROID.md create mode 100644 samples/Android/README.md diff --git a/README.md b/README.md index ac8358242..295aafcab 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ to Java by the [aws-crt-java](https://github.com/awslabs/aws-crt-java) package. *__Jump To:__* * [Installation](#installation) +* [Android](./documents/ANDROID.md) * [Samples](samples) * [Getting Help](#getting-help) * [FAQ](./documents/FAQ.md) @@ -103,51 +104,6 @@ cd aws-iot-device-sdk-java-v2 # Compile and install mvn clean install ``` - -#### Android - -Supports API 26 or newer. -NOTE: The shadow sample does not currently complete on android due to its dependence on stdin keyboard input. - -``` sh -# Create a workspace directory to hold all the SDK files -mkdir sdk-workspace -cd sdk-workspace -# Clone the CRT repository -# (Use the latest version of the CRT here instead of "v0.27.3") -git clone --branch v0.27.3 --recurse-submodules https://github.com/awslabs/aws-crt-java.git -# Compile and install the CRT for Android -cd aws-crt-java/android -./gradlew connectedCheck # optional, will run the unit tests on any connected devices/emulators -./gradlew publishToMavenLocal -# Clone the SDK repository -cd ../.. -git clone https://github.com/awslabs/aws-iot-device-sdk-java-v2.git -# Compile and install -cd aws-iot-device-sdk-java-v2/android -./gradlew publishToMavenLocal -./gradlew installDebug # optional, will install the IoTSamples app to any connected devices/emulators -``` - -Add the following to your project's build.gradle: - -``` groovy -repositories { - mavenCentral() - maven { - url System.getenv('HOME') + "/.m2/repository" - } -} - -dependencies { - implementation 'software.amazon.awssdk.crt:android:0.27.3' -} -``` -[Android IoT Samples README](./android/app/src/main/assets/README.md) - -Replace `0.27.3` in `software.amazon.awssdk.crt:android:0.27.3` with the latest version of the CRT. -Look up the latest CRT version here: https://github.com/awslabs/aws-crt-java/releases - ## Samples [Samples README](samples) diff --git a/documents/ANDROID.md b/documents/ANDROID.md new file mode 100644 index 000000000..68b8514ea --- /dev/null +++ b/documents/ANDROID.md @@ -0,0 +1,95 @@ +# AWS IoT Device SDK for Android + +This document provides information about building and using the AWS IoT device SDK for Java V2 with Android. + +If you have any issues or feature requests, please file an issue or pull request. + +API documentation: https://aws.github.io/aws-iot-device-sdk-java-v2/ + +This SDK is built on the AWS Common Runtime, a collection of libraries +([aws-c-common](https://github.com/awslabs/aws-c-common), +[aws-c-io](https://github.com/awslabs/aws-c-io), +[aws-c-mqtt](https://github.com/awslabs/aws-c-mqtt), +[aws-c-http](https://github.com/awslabs/aws-c-http), +[aws-c-cal](https://github.com/awslabs/aws-c-cal), +[aws-c-auth](https://github.com/awslabs/aws-c-auth), +[s2n](https://github.com/awslabs/s2n)...) written in C to be +cross-platform, high-performance, secure, and reliable. The libraries are bound +to Java by the [aws-crt-java](https://github.com/awslabs/aws-crt-java) package. +An Android library of the aws-crt-java package is built from the same library and is +a dependency of the aws-iot-device-sdk-android library. + +*__Jump To:__* + +* [Installation](#installation) + * [Minimum requirements](#minimum-requirements) + * [Build and install IoT Device SDK from source](#build-and-install-iot-device-sdk-from-source) +* [Consuming IoT Device SDK Android](#consuming-from-locally-installed) + * [Consuming from Maven](#consuming-from-maven) + * [Consuming from locally installed](#consuming-from-locally-installed) +* [Samples App](#samples-app) + +## Installation + +### Minimum requirements +* Java 11+ ([Download and Install Java](https://www.java.com/en/download/help/download_options.html)) + * [Set JAVA_HOME](./documents/PREREQUISITES.md#set-java_home) +* Gradle 7.4.2 ([Download and Install Gradle](https://gradle.org/install/)) +* Android SDK 26 ([Doanload SDK Manager](https://developer.android.com/tools/releases/platform-tools#downloads)) + * [Set ANDROID_HOME](./documents/PREREQUISITES.md#set-android_home) + +### Build and install IoT Device SDK from source +Supports API 26 or newer. +NOTE: The shadow sample does not currently complete on android due to its dependence on stdin keyboard input. + +``` sh +# Create a workspace directory to hold all the SDK files +mkdir sdk-workspace +cd sdk-workspace +# Clone the SDK repository +# (Use the latest version of the SDK here instead of "v1.17.0) +git clone --branch v1.17.0 --recurse-submodules https://github.com/aws/aws-iot-device-sdk-java-v2.git +# Compile and install the SDK for Android +cd aws-iot-device-sdk-java-v2/android +./gradlew build +# Install SDK locally +./gradlew publishToMavenLocal +``` + +## Consuming IoT Device SDK Android + +### Consuming from Maven +Consuming this SDK via Maven is the preferred method of consuming it and using it within your application. To consume +IoT Device SDK Android in your application, add the following to your `build.gradle` repositories and dependencies: + +``` groovy +repositories { + mavenCentral() +} + +dependencies { + api 'software.amazon.awssdk.iotdevicesdk:aws-iot-device-sdk-android:1.17.0' +} +``` +Replace `1.17.0` in `software.amazon.awssdk.iotdevicesdk:aws-iot-device-sdk-android:1.17.0` with the latest release version for the SDK. +Look up the latest SDK version here: https://github.com/aws/aws-iot-device-sdk-java-v2/releases + +### Consuming from locally installed +You may also consume IoT Device SDK Android in your application using a locally installed version by adding the +following to your `build.gradle` repositories and depenencies: +``` groovy +repositories { + mavenLocal() +} + +dependencies { + api 'software.amazon.awssdk.iotdevicesdk:aws-iot-device-sdk-android:1.17.0' +} +``` +Replace `1.17.0` in `software.amazon.awssdk.iotdevicesdk:aws-iot-device-sdk-android:1.17.0` with the latest release version for the SDK +or replace with `1.0.0-SNAPSHOT` to use the SDK built and installed from source. +Look up the latest SDK version here: https://github.com/aws/aws-iot-device-sdk-java-v2/releases + +## Samples App +[Android IoT Samples App README](./samples/Android/README.md) + diff --git a/documents/PREREQUISITES.md b/documents/PREREQUISITES.md index 852b941ae..72c38a858 100644 --- a/documents/PREREQUISITES.md +++ b/documents/PREREQUISITES.md @@ -289,3 +289,20 @@ Or using the command line: 3. After CMake has installed, close the terminal and reopen it 4. Type `cmake --version` to confirm CMake is installed. +## Set ANDROID_HOME +Below are instructions on how you can set `ANDROID_HOME`, which varies from depending on whether you are on Windows or are on MacOS/Linux: + +### Windows +1. Open "Edit the system environment variable" +2. Click "New" to create new environment variable + - variable name: `ANDROID_HOME` + - variable value: `` (example: `C:\Users\YourUsername\AppData\Local\Android\Sdk`) +3. Press "Ok" to save the changes +4. re-open the command prompt for the environment variables to apply + +### MacOS and Linux +Run the following command to set the JAVA_PATH +``` sh +# (example: "/Users/YourUsername/Library/Android/sdk") +export ANDROID_HOME= +``` \ No newline at end of file diff --git a/samples/Android/README.md b/samples/Android/README.md new file mode 100644 index 000000000..6784907bc --- /dev/null +++ b/samples/Android/README.md @@ -0,0 +1,79 @@ +# Sample Application for the AWS IoT Device SDK Android +[**Return to AWS IoT Device SDK for Android README**](../../documents/ANDROID.md) + +The Android sample builds an app that can be installed and run on an Android Device. The app builds and allows you +to run the following [samples](#links-to-sample-readme) from aws-iot-device-sdk-java-v2: +* BasicPubSub +* Mqtt5PubSub +* Jobs +* Shadow +* CognitoConnect + +*__Jump To:__* + +* [Prerequisites](#prerequisites) + * [Files required to run samples](#files-required-to-run-samples) +* [Build and install sample app](#build-and-install-sample-app) +* [Links to sample README](#links-to-sample-readme) + + +# Prerequisites +The individual samples within the app require specific files to operate. The files must be placed in the +`app/src/main/assets` directory prior to building for the sample app to connect to IoT Core and complete +succesfully. The names of the files must be exactly as provided. Explanations for what each file and +associated argument are doing can be found in the individual [Sample README](#links-to-sample-readme) +files linked below. + +## Files required to run samples + +### Files required by all samples: +* `endpoint.txt` - IoT ATS Endpoint + +### Required to run BasicPubSub, Mqtt5PubSub, Jobs, and Shadow samples +* `certificate.pem` - IoT Thing Certificate +* `privatekey.pem` - IoT Thing Private Key + +### Required to run Cognito Client sample: +* `cognitoIdentity.txt` - Cognito identity ID +* `signingRegion.txt` - Signing region + +### Optional files: +* `rootca.pem` - override the default system trust store +* `clientId.txt` - specifies --clientId CLI argument +* `topic.txt` - specifies --topic CLI argument +* `message.txt` - specifies --message CLI argument +* `port.txt` - specifies --port CLI argument +* `thingName.txt` - specifies --thingName CLI argument + +# Build and install sample app + +``` sh +cd samples/Android +# Create a workspace directory to hold all the SDK files +mkdir sdk-workspace +cd sdk-workspace +# Clone the SDK repository +# (Use the latest version of the SDK here instead of "v1.17.0) +git clone --branch v1.17.0 --recurse-submodules https://github.com/aws/aws-iot-device-sdk-java-v2.git +# Compile and install the SDK for Android +cd aws-iot-device-sdk-java-v2/android +./gradlew build +# Install SDK locally +./gradlew publishToMavenLocal +``` + +# Links to sample README +The following links will provide more details on the individual samples available in the +Android sample app. + +[**BasicPubSub**](../BasicPubSub/README.md) + +[**Mqtt5PubSub**](../Mqtt5/PubSub/README.md) + +[**Jobs**](../Jobs/README.md) + +[**Shadow**](../Shadow/README.md) + +[**CognitoConnect**](../CognitoConnect/README.md) + +##### NOTE: The shadow sample does not currently complete on android due to its dependence on stdin keyboard input. \ No newline at end of file From 680c9b4ad99ce9a524e938c68a0a295d9efcedd4 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Wed, 27 Sep 2023 15:00:21 -0700 Subject: [PATCH 05/12] required sample files --- samples/Android/app/gradle.properties | 21 +++++++++++++++++++++ samples/Android/app/settings.gradle | 3 +++ 2 files changed, 24 insertions(+) create mode 100644 samples/Android/app/gradle.properties create mode 100644 samples/Android/app/settings.gradle diff --git a/samples/Android/app/gradle.properties b/samples/Android/app/gradle.properties new file mode 100644 index 000000000..376270d77 --- /dev/null +++ b/samples/Android/app/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official \ No newline at end of file diff --git a/samples/Android/app/settings.gradle b/samples/Android/app/settings.gradle new file mode 100644 index 000000000..6c89b811d --- /dev/null +++ b/samples/Android/app/settings.gradle @@ -0,0 +1,3 @@ +/* + * Necessary gradle file for the sample + */ \ No newline at end of file From d5e6b42e76917ef45352528977cb7c80f15c9945 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Wed, 27 Sep 2023 15:10:16 -0700 Subject: [PATCH 06/12] Update READMEs --- samples/Android/README.md | 19 ++++------- samples/Android/app/src/main/assets/README.md | 33 ------------------- 2 files changed, 7 insertions(+), 45 deletions(-) delete mode 100644 samples/Android/app/src/main/assets/README.md diff --git a/samples/Android/README.md b/samples/Android/README.md index 6784907bc..ec4741e9f 100644 --- a/samples/Android/README.md +++ b/samples/Android/README.md @@ -48,18 +48,13 @@ files linked below. # Build and install sample app ``` sh -cd samples/Android -# Create a workspace directory to hold all the SDK files -mkdir sdk-workspace -cd sdk-workspace -# Clone the SDK repository -# (Use the latest version of the SDK here instead of "v1.17.0) -git clone --branch v1.17.0 --recurse-submodules https://github.com/aws/aws-iot-device-sdk-java-v2.git -# Compile and install the SDK for Android -cd aws-iot-device-sdk-java-v2/android -./gradlew build -# Install SDK locally -./gradlew publishToMavenLocal +# Change to the app directory +cd samples/Android/app +# Use gradlew from the android folder to build the sample app +../../../android/gradlew build + +# Install it to a connected Device +../../../android/gradlew installDebug ``` # Links to sample README diff --git a/samples/Android/app/src/main/assets/README.md b/samples/Android/app/src/main/assets/README.md deleted file mode 100644 index 83168ded7..000000000 --- a/samples/Android/app/src/main/assets/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# Android App -[**Return to aws-iot-device-sdk-java-v2 README**](../../../../../../aws-iot-device-sdk-java-v2/README.md) - -# Files used by IoT Samples App -Files must be placed in the assets directory for the sample app to connect to IoT Core. -## Required by all samples: -* endpoint.txt - IoT ATS Endpoint - -## Requiret to run BasicPubSub, Jobs, and Shadow samples -* certificate.pem - IoT Thing Certificate -* privatekey.pem - IoT Thing Private Key -## Required to run Cognito Client sample: -* cognitoIdentity.txt - Cognito identity ID -* signingRegion.txt - Signing region - - -## Optional files: -* rootca.pem - override the default system trust store -* clientId.txt - specifies --clientId CLI argument -* topic.txt - specifies --topic CLI argument -* message.txt - specifies --message CLI argument -* port.txt - specifies --port CLI argument -* thingName.txt - specifies --thingName CLI argument - -# Links to samples -[**BasicPubSub**](../../../../../samples/BasicPubSub/README.md) - -[**Jobs**](../../../../../samples/Jobs/README.md) - -[**Shadow**](../../../../../samples/Shadow/README.md) - -[**CognitoConnect**](../../../../../samples/CognitoConnect/README.md) -##### NOTE: The shadow sample does not currently complete on android due to its dependence on stdin keyboard input. \ No newline at end of file From 2755234d2e11056d0485dbc5117d5c315314d458 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Wed, 27 Sep 2023 15:15:04 -0700 Subject: [PATCH 07/12] Add Android to FAQ --- documents/FAQ.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/documents/FAQ.md b/documents/FAQ.md index 93e0224e6..4e3ae958b 100644 --- a/documents/FAQ.md +++ b/documents/FAQ.md @@ -8,6 +8,7 @@ * [Mac-Only TLS Behavior](#mac-only-tls-behavior) * [How do debug in VSCode?](#how-do-debug-in-vscode) * [What certificates do I need?](#what-certificates-do-i-need) +* [How do I build and use the Android SDK](#how-do-i-build-and-use-the-android-sdk) * [I still have more questions about this sdk?](#i-still-have-more-questions-about-this-sdk) ### Where should I start? @@ -110,6 +111,8 @@ Here is an example launch.json file to run the pubsub sample * You should have generated/downloaded private and public keys that will be used to verify that communications are coming from you * When using samples you only need the private key and it will look like this: `--key abcde12345-private.pem.key` +### How do I build and use the Android SDK? +Instructions for building, installing, and use of the Android SDK can be found [here](../documents/ANDROID.md) ### I still have more questions about this sdk? * [Here](https://docs.aws.amazon.com/iot/latest/developerguide/what-is-aws-iot.html) are the AWS IoT Core docs for more details about IoT Core From 1911b1240ccde2a138d535c46383567111432d05 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Thu, 28 Sep 2023 10:15:51 -0700 Subject: [PATCH 08/12] update-crt update reflecting README changes --- samples/Android/.gitignore | 1 + samples/Android/app/.gitignore | 3 ++- samples/README.md | 1 + update-crt.py | 18 +++++++++--------- 4 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 samples/Android/.gitignore diff --git a/samples/Android/.gitignore b/samples/Android/.gitignore new file mode 100644 index 000000000..6b19dc7f4 --- /dev/null +++ b/samples/Android/.gitignore @@ -0,0 +1 @@ +/.gradle \ No newline at end of file diff --git a/samples/Android/app/.gitignore b/samples/Android/app/.gitignore index faccdaf50..c44c2dd68 100644 --- a/samples/Android/app/.gitignore +++ b/samples/Android/app/.gitignore @@ -1,3 +1,4 @@ /build ./gradle -/local.properties \ No newline at end of file +/local.properties +/.gradle \ No newline at end of file diff --git a/samples/README.md b/samples/README.md index eed0e9dcf..566d15574 100644 --- a/samples/README.md +++ b/samples/README.md @@ -18,6 +18,7 @@ * [Greengrass IPC](./GreengrassIPC/README.md) * [MQTT5 PubSub](./Mqtt5/PubSub/README.md) * [MQTT5 Shared Subscription](./Mqtt5/SharedSubscription/README.md) +* [Android Sample](./Android/README.md) ### Note diff --git a/update-crt.py b/update-crt.py index 13358ebef..9bbb9158e 100755 --- a/update-crt.py +++ b/update-crt.py @@ -58,21 +58,21 @@ def main(): update(filepath='README.md', preceded_by=r'--branch v', followed_by=r' .*aws-crt-java.git') - update(filepath='README.md', - preceded_by=r"implementation 'software.amazon.awssdk.crt:android:", - followed_by=r"'") + # update(filepath='README.md', + # preceded_by=r"implementation 'software.amazon.awssdk.crt:android:", + # followed_by=r"'") update(filepath='android/iotdevicesdk/build.gradle', preceded_by=r"api 'software.amazon.awssdk.crt:aws-crt-android:", followed_by=r"'") update(filepath='README.md', preceded_by=r'Use the latest version of the CRT here instead of ".*', followed_by=r'"') - update(filepath='README.md', - preceded_by=r"Replace `", - followed_by=r"` in .* with the latest version of the CRT.") - update(filepath='README.md', - preceded_by=r"Replace .* in `software.amazon.awssdk.crt:android:", - followed_by=r"` with the latest version of the CRT.") + # update(filepath='README.md', + # preceded_by=r"Replace `", + # followed_by=r"` in .* with the latest version of the CRT.") + # update(filepath='README.md', + # preceded_by=r"Replace .* in `software.amazon.awssdk.crt:android:", + # followed_by=r"` with the latest version of the CRT.") def update(*, filepath, preceded_by, followed_by, force_version=None): From 48cd2c6693a674aca2557248c4dc302428a8628e Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Thu, 28 Sep 2023 11:19:38 -0700 Subject: [PATCH 09/12] doc fixes --- documents/ANDROID.md | 1 + samples/Android/README.md | 6 +++--- update-crt.py | 9 --------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/documents/ANDROID.md b/documents/ANDROID.md index 68b8514ea..5cb535cc6 100644 --- a/documents/ANDROID.md +++ b/documents/ANDROID.md @@ -59,6 +59,7 @@ cd aws-iot-device-sdk-java-v2/android ## Consuming IoT Device SDK Android ### Consuming from Maven +##### NOTE: aws-iot-device-sdk-android is not currently available in Maven but will be shortly. For now, please publish to maven locally and [Consume from locally installed](#consuming-from-locally-installed) Consuming this SDK via Maven is the preferred method of consuming it and using it within your application. To consume IoT Device SDK Android in your application, add the following to your `build.gradle` repositories and dependencies: diff --git a/samples/Android/README.md b/samples/Android/README.md index ec4741e9f..20ebfefcc 100644 --- a/samples/Android/README.md +++ b/samples/Android/README.md @@ -14,14 +14,14 @@ to run the following [samples](#links-to-sample-readme) from aws-iot-device-sdk- * [Prerequisites](#prerequisites) * [Files required to run samples](#files-required-to-run-samples) * [Build and install sample app](#build-and-install-sample-app) -* [Links to sample README](#links-to-sample-readme) +* [Links to sample README](#links-to-individual-sample-readme-files) # Prerequisites The individual samples within the app require specific files to operate. The files must be placed in the `app/src/main/assets` directory prior to building for the sample app to connect to IoT Core and complete succesfully. The names of the files must be exactly as provided. Explanations for what each file and -associated argument are doing can be found in the individual [Sample README](#links-to-sample-readme) +associated argument are doing can be found in the individual [Sample README](#links-to-individual-sample-readme-files) files linked below. ## Files required to run samples @@ -57,7 +57,7 @@ cd samples/Android/app ../../../android/gradlew installDebug ``` -# Links to sample README +# Links to individual sample README files The following links will provide more details on the individual samples available in the Android sample app. diff --git a/update-crt.py b/update-crt.py index 9bbb9158e..2028e0dcb 100755 --- a/update-crt.py +++ b/update-crt.py @@ -58,21 +58,12 @@ def main(): update(filepath='README.md', preceded_by=r'--branch v', followed_by=r' .*aws-crt-java.git') - # update(filepath='README.md', - # preceded_by=r"implementation 'software.amazon.awssdk.crt:android:", - # followed_by=r"'") update(filepath='android/iotdevicesdk/build.gradle', preceded_by=r"api 'software.amazon.awssdk.crt:aws-crt-android:", followed_by=r"'") update(filepath='README.md', preceded_by=r'Use the latest version of the CRT here instead of ".*', followed_by=r'"') - # update(filepath='README.md', - # preceded_by=r"Replace `", - # followed_by=r"` in .* with the latest version of the CRT.") - # update(filepath='README.md', - # preceded_by=r"Replace .* in `software.amazon.awssdk.crt:android:", - # followed_by=r"` with the latest version of the CRT.") def update(*, filepath, preceded_by, followed_by, force_version=None): From 4d630548a888ac1449f5982dfb87080357ea34dc Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Thu, 28 Sep 2023 14:31:46 -0700 Subject: [PATCH 10/12] pr fixes --- documents/FAQ.md | 2 +- samples/Android/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/documents/FAQ.md b/documents/FAQ.md index 4e3ae958b..de334eed7 100644 --- a/documents/FAQ.md +++ b/documents/FAQ.md @@ -8,7 +8,7 @@ * [Mac-Only TLS Behavior](#mac-only-tls-behavior) * [How do debug in VSCode?](#how-do-debug-in-vscode) * [What certificates do I need?](#what-certificates-do-i-need) -* [How do I build and use the Android SDK](#how-do-i-build-and-use-the-android-sdk) +* [How do I build and use the Android SDK?](#how-do-i-build-and-use-the-android-sdk) * [I still have more questions about this sdk?](#i-still-have-more-questions-about-this-sdk) ### Where should I start? diff --git a/samples/Android/README.md b/samples/Android/README.md index 20ebfefcc..755fea9d6 100644 --- a/samples/Android/README.md +++ b/samples/Android/README.md @@ -2,7 +2,7 @@ [**Return to AWS IoT Device SDK for Android README**](../../documents/ANDROID.md) The Android sample builds an app that can be installed and run on an Android Device. The app builds and allows you -to run the following [samples](#links-to-sample-readme) from aws-iot-device-sdk-java-v2: +to run the following [samples](#links-to-individual-sample-readme-files) from aws-iot-device-sdk-java-v2: * BasicPubSub * Mqtt5PubSub * Jobs From 36313cc099cba14e5009a2c7940eb654e7c65625 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Thu, 28 Sep 2023 14:35:13 -0700 Subject: [PATCH 11/12] pr fixes --- documents/ANDROID.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documents/ANDROID.md b/documents/ANDROID.md index 5cb535cc6..1ddc309b7 100644 --- a/documents/ANDROID.md +++ b/documents/ANDROID.md @@ -33,10 +33,10 @@ a dependency of the aws-iot-device-sdk-android library. ### Minimum requirements * Java 11+ ([Download and Install Java](https://www.java.com/en/download/help/download_options.html)) - * [Set JAVA_HOME](./documents/PREREQUISITES.md#set-java_home) + * [Set JAVA_HOME](./PREREQUISITES.md#set-java_home) * Gradle 7.4.2 ([Download and Install Gradle](https://gradle.org/install/)) * Android SDK 26 ([Doanload SDK Manager](https://developer.android.com/tools/releases/platform-tools#downloads)) - * [Set ANDROID_HOME](./documents/PREREQUISITES.md#set-android_home) + * [Set ANDROID_HOME](./PREREQUISITES.md#set-android_home) ### Build and install IoT Device SDK from source Supports API 26 or newer. From 897a0b98c71b100b3089f11fc688c5ee9e2d6a1c Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Thu, 28 Sep 2023 14:37:02 -0700 Subject: [PATCH 12/12] pr fixes --- documents/ANDROID.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documents/ANDROID.md b/documents/ANDROID.md index 1ddc309b7..2f8021512 100644 --- a/documents/ANDROID.md +++ b/documents/ANDROID.md @@ -92,5 +92,5 @@ or replace with `1.0.0-SNAPSHOT` to use the SDK built and installed from source. Look up the latest SDK version here: https://github.com/aws/aws-iot-device-sdk-java-v2/releases ## Samples App -[Android IoT Samples App README](./samples/Android/README.md) +[Android IoT Samples App README](../samples/Android/README.md)