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 34

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 folowing 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

Disable R8 full mode, use AndroidX and enable Jetifier like below;

 android.enableR8.fullMode=false
android.useAndroidX=true
android.enableJetifier=true

ProGuard Rules

  • If you're using ProGuard in your application, you must add the following block to your rules.
-keep class ai.** {*;}
-dontwarn ai.**
-keep class datamanager.** {*;}
-dontwarn datamanager.**
-keep class networkmanager.** {*;}
-dontwarn networkmanager.**

-keep class org.jmrtd.** {*;}
-keep class net.sf.scuba.** {*;}
-keep class org.bouncycastle.** {*;}
-keep class org.spongycastle.** {*;}
-keep class org.ejbca.** {*;}

-dontwarn org.ejbca.**
-dontwarn org.bouncycastle.**
-dontwarn org.spongycastle.**
-dontwarn org.jmrtd.**
-dontwarn net.sf.scuba.**

Installation

  • Add the dependency to your app's build.gradle
dependencies {
implementation 'ai.amani.android:AmaniAi:3.5.13'
}
  • 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.