Skip to main content

Preparation

To setup Android SDK correctly, you must complete the steps below.

Requirements​

The minimum requirements for the SDK are:

  • API Level 21
  • compileSDKVersion 36

Required Permissions​

This SDK makes use of the devices Camera, Location and NFC permissions. If you don't want to use location service, please provide in init method.

You must have the following keys in your application's manifest file:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc" android:required="false"/>
<uses-permission android:name="android.permission.ScanNFC" />

Gradle Properties​

Use AndroidX and enable Jetifier like below;

android.useAndroidX=true
android.enableJetifier=true

ProGuard / R8 Rules​

From v3.24.0, the SDK supports R8 full mode (the default since Android Gradle Plugin 8.0). The SDK's ProGuard rules are bundled in the AAR and applied automatically when your app is built with R8, so you do not need to add any rules for the SDK.

  • If your app uses the NFC module, add the following rules for Bouncy Castle, which loads its cryptography classes by name:
-keep class org.bouncycastle.** { *; }
-dontwarn org.bouncycastle.**
note

Upgrading from an earlier version? Remove the SDK rules you added before (-keep class ai.** {*;}, datamanager.**, networkmanager.**, org.jmrtd.**, net.sf.scuba.**, org.spongycastle.**, org.ejbca.**). They are no longer needed and make your app larger.

Installation​

Release

  • Add the dependency to your app's build.gradle
dependencies {
implementation 'ai.amani.android:AmaniAi:LATEST_RELEASE'
}
  • Enable data binding and configure the aaptOptions block in your Android Gradle setup to prevent TensorFlow Lite model files (.tflite) from being compressed during APK packaging. This ensures that the model files remain directly accessible at runtime without decompression overhead. Additionally, exclude redundant or conflicting metadata files (such as META-INF/versions/9/OSGI-INF/MANIFEST.MF) from the final APK to avoid build-time merge issues when using certain libraries.
android {
// Enable data binding
dataBinding {
enabled = true
}

// Configure aaptOptions to prevent compression of .tflite files
aaptOptions {
noCompress "tflite"
}

// Exclude conflicting or unnecessary metadata to avoid build issues
packaging {
resources {
it.excludes += "META-INF/versions/9/OSGI-INF/MANIFEST.MF"
}
}
}
  • Ensure your project is configured to use the JFrog as a repository source.
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven {
url = "https://jfrog.amani.ai/artifactory/amani-sdk"
}
}
}

You're now ready to use our SDK.