In order to make calls to the IronCore service, you must add a dependency for ironoxide-android, load the library, and provide authentication.
Add the following to your module's "build.gradle":
dependencies {
implementation 'com.ironcorelabs:ironoxide-android:<VERSION>@aar'
}
To load the ironoxide-android
library in Java, use the following:
java.lang.System.loadLibrary("ironoxide_android");
To make calls, you must create a project and segment in the IronCore Admin Console. These are necessary to create an IronCore JWT that can be used to create users and generate devices. The JWT must use either the ES256 or RS256 algorithm and have a payload similar to IronOxide's JwtClaims.
Alternatively, once you have created a project and a segment, you can use a tool such as ironoxide-cli to create users and devices directly.
You can then read in a device with the DeviceContext.fromJsonString()
function and use it to initialize an IronOxide
instance. An example of this is available in the
Example Application in "MainActivity.java".
-
Install Rust toolchain.
-
Install Android SDK 29. You can get the command line SDK here (scroll down to "Command line tools only").
- Note: The extracted
tools
folder must follow a specific folder hierarchy. We recommendAndroidCLI/cmdline-tools/tools
.
- Note: The extracted
-
Install Android 29 build and platform tools. This can be done with
sdkmanager
(found intools/bin
):./sdkmanager "build-tools;29.0.3" "platform-tools" "platforms;android-29"
-
Create the file
$HOME/.gradle/gradle.properties
and add the linesdk.dir=PATH_TO_ANDROID_CLI_FOLDER
.
From the repository root, run android/build.sh
.
This will compile IronOxide-Android for x86_64
Android phones. If building for a different architecture, you can find the Rust target to compile to
here and modify the cargo ndk
command in build.sh
. The compiled library and generated Java files will be put into android/ironoxide-android/src/main
.
- Successfully run
build.sh
by following the steps in Build from Source. - An Android emulator running, or a compatible Android phone connected.
- To start an emulator using the command line tools, follow these steps from the folder
AndroidCLI/cmdline-tools/tools/bin
:./sdkmanager "emulator" "system-images;android-29;google_apis;x86_64"
./avdmanager create avd -n pixel_3 -k "system-images;android-29;google_apis;x86_64" -d pixel_3
../../../emulator/emulator -avd pixel_3 -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim
- The emulator may take some time to boot, but the output will include
emulator: INFO: boot completed
when it has completed. You will need to use a different terminal to run the tests.
- To start an emulator using the command line tools, follow these steps from the folder
Run the tests from the android
folder with:
./gradlew connectedAndroidTest