diff --git a/README.md b/README.md index fb71c1e7..62aa1b93 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,54 @@ # AWS IoT Device SDK for Java v2 -This document provides information about the AWS IoT device SDK for Java V2. This SDK is built on the [AWS Common Runtime](https://docs.aws.amazon.com/sdkref/latest/guide/common-runtime.html) +The AWS IoT Device SDK for Java v2 connects your Java applications and devices to the AWS IoT platform. It handles the complexities of secure communication, authentication, and device management so you can focus on your IoT solution. The SDK makes it easy to use AWS IoT services like Device Shadows, Jobs, Fleet Provisioning, and Commands. -*__Jump To:__* +**Supported Platforms**: Linux, Windows 11+, macOS 14+, Android API level 24+ (Android 7.0+) +> **Note**: The SDK is known to work on older platform versions, but we only guarantee compatibility for the platforms listed above. + +*__Topics:__* +* [Features](#features) * [Installation](#installation) -* [Android](./documents/ANDROID.md) + * [Minimum Requirements](#minimum-requirements) + * [Consuming IoT Device SDK](#consuming-iot-device-sdk-from-maven-in-your-application) +* [Getting Started](#getting-started) * [Samples](samples) -* [Mac-Only TLS Behavior](#mac-only-tls-behavior) -* [Getting Help](#getting-help) -* [FAQ](./documents/FAQ.md) -* [API Docs](https://aws.github.io/aws-iot-device-sdk-java-v2/) * [MQTT5 User Guide](./documents/MQTT5_Userguide.md) -* [Migration Guide from the AWS IoT SDK for Java v1](./documents/MIGRATION_GUIDE.md) +* [Getting Help](#getting-help) +* [Resources](#resources) + +## Features + +The primary purpose of the AWS IoT Device SDK for Java v2 is to simplify the process of connecting devices to AWS IoT Core and interacting with AWS IoT services on various platforms. The SDK provides: + +* Integrated service clients for AWS IoT Core services +* Secure device connections to AWS IoT Core using MQTT protocol including MQTT 5.0 +* Support for [multiple authentication methods and connection types](./documents/MQTT5_Userguide.md#how-to-setup-mqtt5-builder-based-on-desired-connection-method) +* Android [support](./documents/ANDROID.md) + +#### Supported AWS IoT Core services + +* The [AWS IoT Device Shadow](https://docs.aws.amazon.com/iot/latest/developerguide/iot-device-shadows.html) service manages device state information in the cloud. +* The [AWS IoT Jobs](https://docs.aws.amazon.com/iot/latest/developerguide/iot-jobs.html) service sends remote operations to connected devices. +* The [AWS IoT fleet provisioning](https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html) service generates and delivers device certificates automatically. +* The [AWS IoT Device Management commands](https://docs.aws.amazon.com/iot/latest/developerguide/iot-remote-command.html) service sends instructions from the cloud to connected devices. ## Installation +The recommended way to use the AWS IoT Device SDK for Java v2 in your project is to consume it from Maven Central. + ### Minimum Requirements +To develop applications that use AWS IoT Device SDK for Java v2, you need: * Java 8+ ([Download and Install Java](https://www.java.com/en/download/help/download_options.html)) -* Java JDK 8+ ([Download and Install JDK](https://docs.oracle.com/en/java/javase/18/install/overview-jdk-installation.html#GUID-8677A77F-231A-40F7-98B9-1FD0B48C346A)) - * [Set JAVA_HOME](./documents/PREREQUISITES.md#set-java_home) - -[Step-by-step instructions](./documents/PREREQUISITES.md) - -### Requirements to build the AWS CRT locally -* C++ 11 or higher - * Clang 3.9+ or GCC 4.4+ or MSVC 2015+ -* CMake 3.1+ +* Java JDK 8+ ([Download and Install JDK](https://docs.oracle.com/en/java/javase/18/install/overview-jdk-installation.html)) +* A build tool such as [Maven](https://maven.apache.org/install.html) -[Step-by-step instructions](./documents/PREREQUISITES.md) +See [detailed setup instructions](./documents/PREREQUISITES.md) for more information. ### Consuming IoT Device SDK from Maven in your application -Consuming this SDK via Maven is the preferred method of consuming it and using it within your application. To consume the Java V2 SDK in your application, add the following to your `pom.xml` dependencies: +Add the following to your `pom.xml` dependencies: ``` xml @@ -46,57 +61,65 @@ Consuming this SDK via Maven is the preferred method of consuming it and using i Replace `1.27.4` in `1.27.4` 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 -### Build IoT Device SDK from source +### Building AWS IoT SDK from source -[Install Maven and Set PATH](https://maven.apache.org/install.html) +See the [Development Guide](./documents/DEVELOPING.md) for detailed instructions on building from source and using local builds. -``` sh -# Create a workspace directory to hold all the SDK files -mkdir sdk-workspace -cd sdk-workspace -# Clone the repository -git clone https://github.com/awslabs/aws-iot-device-sdk-java-v2.git -cd aws-iot-device-sdk-java-v2 -# Compile and install -mvn clean install -``` +## Getting Started + +To get started with the AWS IoT Device SDK for Java v2: + +1. Add the SDK to your project - See the [Installation](#installation) section for Maven dependency details + +2. Choose your connection method - The SDK supports multiple authentication methods including X.509 certificates, AWS credentials, and custom authentication. [MQTT5 User Guide connection section](./documents/MQTT5_Userguide.md#how-to-setup-mqtt5-builder-based-on-desired-connection-method) and [MQTT5 X509 sample](./samples/Mqtt/Mqtt5X509/README.md) provide more guidance -If you wish to use the latest CRT release, rather than the latest tested with the IoT SDK, you can run the following before running `mvn clean install`: +3. Follow a complete example - Check out the [samples](samples) directory -~~~ sh -# Update the version of the CRT being used -mvn versions:use-latest-versions -Dincludes="software.amazon.awssdk.crt*" -~~~ +4. Learn MQTT5 features - For advanced usage and configuration options, see the [MQTT5 User Guide](./documents/MQTT5_Userguide.md) ## Samples -[Samples README](samples) +Check out the [samples](samples) directory for working code examples that demonstrate: +- [Basic MQTT connection and messaging](./samples/README.md#mqtt5-client-samples) +- [AWS IoT Device Shadow operations](./samples/ServiceClients/ShadowSandbox/README.md) +- [AWS IoT Jobs](./samples/ServiceClients/JobsSandbox/README.md) +- AWS IoT Fleet provisioning: [basic](./samples/ServiceClients/Provisioning/Basic/README.md) and [with CSR](./samples/ServiceClients/Provisioning/Csr/README.md) +- [AWS IoT Commands](./samples/ServiceClients/CommandsSandbox/README.md) + +The samples provide ready-to-run code with detailed setup instructions for each authentication method and use case. + +## Getting Help + +The best way to interact with our team is through GitHub. +* Open [discussion](https://github.com/aws/aws-iot-device-sdk-java-v2/discussions): Share ideas and solutions with the SDK community +* Search [issues](https://github.com/aws/aws-iot-device-sdk-java-v2/issues): Find created issues for answers based on a topic +* Create an [issue](https://github.com/aws/aws-iot-device-sdk-java-v2/issues/new/choose): New feature request or file a bug + +If you have a support plan with [AWS Support](https://aws.amazon.com/premiumsupport/), you can also create a new support case. -### Mac-Only TLS Behavior +#### Mac-Only TLS Behavior + +> [!NOTE] +> This SDK does not support TLS 1.3 on macOS. Support for TLS 1.3 on macOS is planned for a future release. Please note that on Mac, once a private key is used with a certificate, that certificate-key pair is imported into the Mac Keychain. All subsequent uses of that certificate will use the stored private key and ignore anything passed in programmatically. Beginning in v1.7.3, when a stored private key from the Keychain is used, the following will be logged at the "info" log level: ``` -static: certificate has an existing certificate-key pair that was previously imported into the Keychain. Using key from Keychain instead of the one provided. +static: certificate has an existing certificate-key pair that was previously imported into the Keychain. + Using key from Keychain instead of the one provided. ``` -## Getting Help +## Resources -The best way to interact with our team is through GitHub. You can open a [discussion](https://github.com/aws/aws-iot-device-sdk-java-v2/discussions) for guidance questions or an [issue](https://github.com/aws/aws-iot-device-sdk-java-v2/issues/new/choose) for bug reports, or feature requests. You may also find help on community resources such as [StackOverFlow](https://stackoverflow.com/questions/tagged/aws-iot) with the tag [#aws-iot](https://stackoverflow.com/questions/tagged/aws-iot) or if you have a support plan with [AWS Support](https://aws.amazon.com/premiumsupport/), you can also create a new support case. - -Please make sure to check out our resources too before opening an issue: +Check out our resources for additional guidance too before opening an issue: * [FAQ](./documents/FAQ.md) -* [IoT Guide](https://docs.aws.amazon.com/iot/latest/developerguide/what-is-aws-iot.html) ([source](https://github.com/awsdocs/aws-iot-docs)) +* [AWS IoT Core Developer Guide](https://docs.aws.amazon.com/iot/latest/developerguide/what-is-aws-iot.html) * [MQTT5 User Guide](./documents/MQTT5_Userguide.md) -* Check for similar [Issues](https://github.com/aws/aws-iot-device-sdk-java-v2/issues) +* [API Docs](https://aws.github.io/aws-iot-device-sdk-java-v2/) * [AWS IoT Core Documentation](https://docs.aws.amazon.com/iot/) -* [Dev Blog](https://aws.amazon.com/blogs/?awsf.blog-master-iot=category-internet-of-things%23amazon-freertos%7Ccategory-internet-of-things%23aws-greengrass%7Ccategory-internet-of-things%23aws-iot-analytics%7Ccategory-internet-of-things%23aws-iot-button%7Ccategory-internet-of-things%23aws-iot-device-defender%7Ccategory-internet-of-things%23aws-iot-device-management%7Ccategory-internet-of-things%23aws-iot-platform) -* Integration with AWS IoT Services such as -[Device Shadow](https://docs.aws.amazon.com/iot/latest/developerguide/iot-device-shadows.html) -[Jobs](https://docs.aws.amazon.com/iot/latest/developerguide/iot-jobs.html) -[Fleet Provisioning](https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html) -is provided by code that been generated from a model of the service. +* [Dev Blog](https://aws.amazon.com/blogs/iot/category/internet-of-things/) +* [Migration Guide from the AWS IoT SDK for Java v1](./documents/MIGRATION_GUIDE.md) * [Contributions Guidelines](./documents/CONTRIBUTING.md) * [DEVELOPING](./documents/DEVELOPING.md) diff --git a/documents/DEVELOPING.md b/documents/DEVELOPING.md index 82307ceb..9d3ace7c 100644 --- a/documents/DEVELOPING.md +++ b/documents/DEVELOPING.md @@ -1,35 +1,64 @@ -# Developing Instructions +# Development Guide -Please first follow the instructions in the [main readme](../README.md) +This guide covers building and developing with the AWS IoT Device SDK for Java v2. -## Consuming Local IoT Device SDK from Maven in your application -To build the SDK locally and test local changes do the following: +**Prerequisites:** Follow the setup instructions in the [main README](../README.md) first. -Modify [sdk/pom.xml](https://github.com/aws/aws-iot-device-sdk-java-v2/sdk/pom.xml) -``` xml +## Building from Source + +### Basic Build + +```bash +# Create workspace directory +mkdir sdk-workspace +cd sdk-workspace + +# Clone the repository +git clone https://github.com/awslabs/aws-iot-device-sdk-java-v2.git +cd aws-iot-device-sdk-java-v2 + +# Build and install +mvn clean install +``` + +### Using Latest CRT Version + +To use the latest AWS CRT release instead of the tested version: + +```bash +# Update CRT version before building +mvn versions:use-latest-versions -Dincludes="software.amazon.awssdk.crt*" +mvn clean install +``` + +## Using Local IoT SDK in Your Application + +### Maven Dependency Configuration + +To test local changes, update your application's `pom.xml`: + +```xml software.amazon.awssdk.iotdevicesdk aws-iot-device-sdk 1.0.0-SNAPSHOT ``` -Note the version number matches the sdk version number in [aws-crt-java](https://github.com/awslabs/aws-crt-java/pom.xml) -under -```xml - 1.0.0-SNAPSHOT -``` -Please note: The default location for local builds with maven is -Linux: /home//.m2 -Windows: C:\Users\\.m2 -Mac: /Users//.m2 +**Note:** Ensure the version matches the SDK version in [aws-crt-java pom.xml](https://github.com/awslabs/aws-crt-java/blob/main/pom.xml). + +### Maven Local Repository -It is safe to delete the whole directory -It is possible to pass this directory as an argument to the maven command +**Default locations:** +- **Linux:** `/home//.m2` +- **Windows:** `C:\Users\\.m2` +- **macOS:** `/Users//.m2` + +**Custom repository location:** ```bash -mvn -Dmaven.repo.local=/my/local/repository/path clean install +mvn -Dmaven.repo.local=/path/to/custom/repo clean install ``` -It is also possible to change it globally by modifying setting.xml in the maven -configuration files -After that making your changes, follow the guide in the [main page](../README.md) +**Global configuration:** Modify `settings.xml` in Maven configuration directory. + +**Cleanup:** The `.m2` directory can be safely deleted to clear local builds. diff --git a/documents/PREREQUISITES.md b/documents/PREREQUISITES.md index 72c38a85..87e33f49 100644 --- a/documents/PREREQUISITES.md +++ b/documents/PREREQUISITES.md @@ -1,53 +1,10 @@ # PREREQUISITES -## Java 8+ +Choose the operating system for instructions: -You can install Java 8+ by following the instructions on the Java website and downloading a build for your operating system: [Download and Install Java](https://www.java.com/en/download/help/download_options.html) - -## JDK 8 or above - -You can install the Java Developer Kit (JDK) 8+ by following the instructions on the Oracle website and downloading a build for your operating system: [Download and install JDK](https://docs.oracle.com/en/java/javase/18/install/overview-jdk-installation.html#GUID-8677A77F-231A-40F7-98B9-1FD0B48C346A) - -## Set JAVA_HOME - -Below are instructions on how you can set `JAVA_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: `JAVA_HOME` - - variable value: `` (example: `C:\Program Files\Java\jdk-17.0.2`) -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: "/Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home") -export JAVA_HOME= -``` - -## C++ 11 Compiler - -To build the SDK, you will need a compiler that can compile C++ 11 code or higher. C++ compilers vary based on platform, but listed below are a few of the most common and the minimum version required: - -* Clang: 3.9 or higher -* GCC: 4.8 or higher -* MSVC: 2015 or higher - -Listed below are ways to install C++ 11 compilers on [Windows](#windows-c-compilers), [MacOS](#macos-c-compiler), and [Linux](#linux-c-compilers). - -## CMake 3.1+ - -You will also need CMake to build the SDK. The minimum required version is CMake 3.1. - -Below are the instructions to install CMake in a non-platform specific way: - -1. Download CMake3.1+ for your platform: https://cmake.org/download/ -2. Run the Cmake Installer. Make sure you add CMake into **PATH**. -3. Restart the command prompt / terminal. - -Listed below are also instructions to install CMake on [Windows](#windows-cmake), [MacOS](#macos-cmake), and [Linux](#linux-cmake). +- [Windows](#windows-instructions) +- [macOS](#macos-instructions) +- [Linux](#linux-instructions) ## Windows Instructions @@ -70,147 +27,44 @@ Below are the steps to set `JAVA_HOME` for Windows: 3. Press "Ok" to save the changes 4. re-open the command prompt for the environment variables to apply -### Windows C++ Compilers - -#### MinGW-w64 - -MinGW-w64 is a project that allows for `GCC` compiler support on Windows. There are several ways to install MinGW-w64, and this document will explain the workflow for adding MinGW-w64 using MSYS2, a software distribution and building platform for Windows. - -MinGW-w64 is fully supported on [Visual Studio Code](https://code.visualstudio.com/), a programming IDE that is a lightweight alternative to Visual Studio that supports many programming languages. The steps below are loosely based on the documentation for [installing MinGW-w64 for Visual Studio code](https://code.visualstudio.com/docs/cpp/config-mingw). - -1. Download and run the MSYS2 installer from the [MSYS2 website](https://www.msys2.org/). -2. Follow the install instructions on the [MSYS2 website](https://www.msys2.org/). - * Make sure to follow the instructions on the website for updating the database and base packages! - * Installing MinGW-w64 may be part of these instructions. If so, install MinGW-w64 using the instructions there. -3. If MinGW-w64 was not part of the install instructions for MSYS2, run `pacman -S --needed base-devel mingw-w64-x85_64-toolchain`. -4. Next you need to add MinGW to your windows `PATH` environment variables so you can run it from the terminal. -5. Open the Windows Settings. You can do this by typing `settings` into the search bar or by opening the Windows start menu and navigating to the Windows Settings (should be called "Settings") application. -6. Once the Windows Settings window is open, search for `Edit environment variables for your account`. -7. Select the `Path` variable in the `User variables` property and press the `Edit` button. -8. Select `New` and then add the MinGW-w64 `bin` folder to this path. If you used the command in step 3, it should be located in `C:\msys64\mingw64\bin`. If you installed using a different method, you will need to find the `mingw64/bin` folder on your computer. -9. Once you have added the path to the `Path` variable in the `User variables` property, select `OK` and save. -10. Close any console/terminal windows you have open. This is because the console/terminal will not see the updated `PATH` variable unless it is restarted by closing and reopening. -11. Confirm that MingW-w64 is installed by running either `g++ --version` or `gdb --version`. You should get a print out showing the installed version of the C++ compiler. - -#### MSVC - -Microsoft Visual C++ (MSVC) is a C++ compiler that is supported and maintained by Microsoft, and is supported by the C++ SDK. To install MSVC, you will need to install Visual Studio using the instructions below. - -Install Visual Studio with MSVC -1. Download **Visual Studio Installer** https://visualstudio.microsoft.com/downloads/ -2. Run the installer, check the **Desktop development with C++** workload and select Install. -3. Verify your MSVC installation - * In Windows Start up Menu, try open "Developer Command Prompt for VS". - * In the opened terminal/console window, type `cl.exe` and it *should* output the compiler version. - * You can also find the compiler version by opening Visual Studio by selecting `help` and then `about`. - -If using MSVC, you will need to use the Developer Command Prompt instead of the standard terminal when compiling the SDK and samples. - -### Windows CMake - -#### MinGW-w64 - -If you installed MinGW-w64 via `MSYS32` in the steps above, you can easily install CMake using the following: - -1. Run `pacman -S mingw-w64-x86_64-cmake`. -2. You will also need to install a build tool. You can install `ninja` or `make`. -3. To install `ninja` run `pacman -S mingw-w64-x86_64-ninja`. -4. To install `make` run `pacman -S mingw-w64-x86_64-make`. -5. Run `cmake --version` to check that CMake is properly installed. - -#### Manual Install - -You can also install CMake manually by following the install instructions on the CMake website: - -1. Download CMake3.1+ for Windows: https://cmake.org/download/ -2. Run the Cmake Installer. -4. Next you need to add CMake to your windows `PATH` environment variables so you can run it from the terminal. - * Note: The installer should include an option to add CMake to the system path for all users. If you have checked this box, you can skip steps `5` through `9`. -5. Open the Windows Settings. You can do this by typing `settings` into the search bar or by opening the Windows start menu and navigating to the Windows Settings (should be called "Settings") application. -6. Once the Windows Settings window is open, search for `Edit environment variables for your account`. -7. Select the `Path` variable in the `User variables` property and press the `Edit` button. -8. Select `New` and then add the CMake `bin` folder to this path. If you do not modify the install path, it should be located around `C:\Program Files (x86)\CMake.x.x` where `x.x` is the version. If you installed CMake to a different directory, then you will need to modify the path accordingly. -9. Once you have added the path to the `Path` variable in the `User variables` property, select `OK` and save. -10. Close any console/terminal windows you have open. This is because the console/terminal will not see the updated `PATH` variable unless it is restarted by closing and reopening. -11. Run `cmake --version` to check that CMake is properly installed. +### Windows ANDROID_HOME +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 Instructions +## macOS Instructions -### MacOS Java 8+ +### macOS Java 8+ -Go to the [download page for Java](https://www.java.com/en/download/) and download the installer for your platform. Once the downloader is installed, launch it and follow the prompts to install Java. You can find detailed steps on installing Java for MacOS on the Java website [page for MacOS](https://www.java.com/en/download/help/download_options.html#mac). +Go to the [download page for Java](https://www.java.com/en/download/) and download the installer for your platform. Once the downloader is installed, launch it and follow the prompts to install Java. You can find detailed steps on installing Java for macOS on the Java website [page for macOS](https://www.java.com/en/download/help/download_options.html#mac). -### MacOS JDK 8+ +### macOS JDK 8+ -Go to the Oracle website [download page for MacOS](https://docs.oracle.com/en/java/javase/18/install/installation-jdk-macos.html#GUID-2FE451B0-9572-4E38-A1A5-568B77B146DE) and download the JDK `dmg` file following the instructions on the `Installing the JDK on MacOS` section. Once the JDK `dmg` is downloaded, launch it and follow the prompts to install the JDK. +Go to the Oracle website [download page for macOS](https://docs.oracle.com/en/java/javase/18/install/installation-jdk-macos.html#GUID-2FE451B0-9572-4E38-A1A5-568B77B146DE) and download the JDK `dmg` file following the instructions on the `Installing the JDK on macOS` section. Once the JDK `dmg` is downloaded, launch it and follow the prompts to install the JDK. -### MacOS JAVA_HOME +### macOS JAVA_HOME -Below are the steps to set `JAVA_HOME` for MacOS: +Below are the steps to set `JAVA_HOME` for macOS: ``` sh -# (example: "/Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home") export JAVA_HOME= ``` +, where `` must be replaced with the JAVA SDK installation directory (for example, `/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home`). -### MacOS C++ Compiler - -#### XCode Command Line Tools using `brew` - -XCode Command Line Tools is the easiest way to install C++ compilers on MacOS, as it is officially supported and maintained by Apple. By installing the XCode Command Line tools, you will automatically install `clang`, which can compile C++ 11 code. One way to install XCode Command Line Tools is using `brew`. - -[Brew](https://brew.sh/) is a command line package manager that makes it easy to install packages and software dependencies. The instructions to install through `brew` are below: - -1. Open a new terminal and input the following command: -``` sh -bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -``` -2. If XCode Command Line Tools are not installed, the `brew` install process will ask if you want to install. Type `y` to install. -3. Wait for `brew` to install the XCode Command Line Tools. This make take some time. -4. Once `brew` is finished, confirm the XCode Command Line Tools have installed by opening a new terminal and inputting `clang --version`. - -If stuck waiting for `brew` to install XCode Command Line Tools for over 15-20 minutes, you many need to cancel the installation (`CTRL-C` in the terminal) and install XCode Command Line Tools though the installer. - -##### XCode Command Line Tools using installer - -You can also install XCode Command Line Tools manually through an installer download on Apple's website. The instructions to install through the installer are below: - -1. Go to [developer.apple.com/downloads](https://developer.apple.com/download/all/). -2. Input your AppleID to access the developer downloads. -3. From the presented list, scroll until you find `Command Line Tools for Xcode `. -4. Select `view more details` and then select `Additionals Tools for Xcode .dmg`. -5. Once downloaded, double click the `.dmg` and follow the installer instructions. -6. Confirm XCode Command Line Tools have installed by opening a new terminal and inputting `clang --version`. - -### MacOS CMake -#### CMake using `brew` - -CMake can easily be installed using `brew`, so if you installed `brew` for XCode Command Line Tools, you can run the following to install CMake: - -1. Confirm you have `brew` installed: -``` sh -brew --version -``` -2. Install CMake by running `brew install cmake`. -3. Close any console/terminal windows you have open. This is to refresh the console/terminal so it uses the latest changes. -4. Confirm CMake is installed by running `cmake --version`. - -#### Manual Install +### macOS ANDROID_HOME -You can also install CMake manually by following the install instructions on the CMake website: +Run the following command to set the ANDROID_HOME environment variable: -1. Go to [cmake.org/install](https://cmake.org/install/). -2. Follow the install instructions for MacOS on the website page. -3. Drag and drop the CMake application from the downloaded installer into your Applications folder. A window should open once you have mounted the CMake installer that easily allows you to do this via drag-and-drop. -4. You may need to manually add CMake to your `path` so you can run it in the terminal. To do this, run the following command: ``` sh -sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install +export ANDROID_HOME= ``` -5. This will create the symlinks so you can run CMake from the terminal. -6. Close any console/terminal windows you have open. This is to refresh the console/terminal so it uses the latest changes. +, where `` must be replaced with the Android SDK installation directory (for example, `/Users/YourUsername/Library/Android/sdk`). -## Linux +## Linux Instructions ### Linux Java 8+ @@ -225,84 +79,15 @@ Go to the Oracle website [download page for Linux](https://docs.oracle.com/en/ja Below are the steps to set `JAVA_HOME` for Linux: ``` sh -# (example: "/usr/lib64/jvm/jdk-10.jdk/jre/bin/java") export JAVA_HOME= ``` +, where `` must be replaced with the JAVA SDK installation directory (for example, `/usr/lib/jvm/jdk-17.jdk`). -### Linux C++ Compilers +### Linux ANDROID_HOME -Many Linux operating systems have C++ compilers installed by default, so you might already `clang` or `gcc` preinstalled. -To test, try running the following in a new terminal: +Run the following command to set the ANDROID_HOME environment variable: ``` sh -clang --version -``` -``` sh -gcc --version -``` - -If these commands fail, then please follow the instructions below for installing a C++ compiler on your Linux operating system. - -If your Linux operating system is not in the list, please use a search engine to find out how to install either `clang` or `gcc` on your Linux operating system. - -#### Install GCC or Clang on Ubuntu - -1. Open a new terminal -2. (optional) Run `sudo apt-get update` to get latest package updates. -3. (optional) Run `sudo apt-get upgrade` to install latest package updates. -4. Run `sudo apt-get install build-essential` to install GCC or `sudo apt-get install clang` to install Clang. -5. Once the install is finished, close the terminal and reopen it. -6. Confirm GCC is installed by running `gcc --version` or Clang is installed by running `clang --version`. - -#### Install GCC or Clang on Arch Linux - -1. Open a new terminal. -2. Run `sudo pacman -S gcc` to install GCC or `sudo pacman -S clang` to install Clang. -3. Once the install is finished, close the terminal and reopen it. -4. Confirm Clang is installed by running `gcc --version`. - -### Linux CMake - -There are several ways to install CMake depending on the Linux operating system. Several Linux operating systems include CMake in their software repository applications, like the Ubuntu Software Center for example, so you may want to check there first. Below are the instructions to install CMake for Ubuntu and Arch Linux. - -If your Linux operating system is not in the list below, please use a search engine to find out how to install CMake on your Linux operating system. You can also always try to install CMake manually using the generic install instructions at the top of this page. - -#### Install CMake on Ubuntu - -1. Open the Ubuntu Software Center -2. In the search bar enter `cmake` and select `CMake - cross-platform build system` from the list -3. Press the `install` button -4. After CMake has installed open a new terminal -5. Type `cmake --version` to confirm CMake is installed - -Or using the command line: - -1. Open a new terminal -2. Run `sudo snap install cmake` to install CMake from the snap store -3. After CMake has installed, close the terminal and reopen it -4. Type `cmake --version` to confirm CMake is installed - -#### Install CMake on Arch Linux - -1. Open a new terminal. -2. Run `sudo pacman -S cmake` to install Cmake -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 +``` +, where `` must be replaced with the Android SDK installation directory (for example, `/home/YourUsername/Library/Android/sdk`).