Android SDK - Getting Started
Quick Start Guide
This guide will lead you through the first steps of integrating the Anyline Tire Tread SDK into your Android app.
You can check out our GitHub repository for a full example implementation of the Anyline Tire Tread SDK. |
Add the Anyline Tire Tread SDK as dependency
The Anyline Tire Tread SDK for Android is available through the maven registry: https://europe-maven.pkg.dev/anyline-ttr-sdk/maven
.
To integrate it, add the Anyline Tire Tread SDK io.anyline.tiretread.sdk:shared
as a dependency to your build.gradle
, along with the activity-compose
dependency and the compose compiler options
.
repositories {
// ... your other repositories ...
mavenCentral()
// Anyline Maven registry
maven { url "https://europe-maven.pkg.dev/anyline-ttr-sdk/maven" }
}
android {
namespace 'your.apps.namespace'
compileSdk 34
defaultConfig {
minSdk 26
targetSdk 34
...
}
buildFeatures {
viewBinding true
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.4"
}
}
dependencies {
// ... your other dependencies ...
// Anyline Tire Tread SDK dependency
// ideally, you should pin (at least) the Major version of the SDK to avoid unexpected breaking changes
implementation 'io.anyline.tiretread.sdk:shared:10.+'
// Include the 'Compose' dependency to be able to
// integrate the TireTreadScanView in your Pages
implementation 'androidx.activity:activity-compose:1.8.1'
//... your other dependencies
}
The Anyline Tire Tread SDK follows the Semantic Versioning. |
Integrate the Anyline License Key
A License Key string will be required in order to run the Anyline Tire Tread SDK on your app.
Store the License Key
You can integrate your license key string in a way that best suits your development workflow.
You can add it to a strings.xml
resource file; have it hard-coded
into your Java/Kotlin file (not recommended, in most cases); securely fetch it
from your back-end server or secret manager/provider; or request your appplication’s user to manually enter
their License Key.
Initialize the Android Tire Tread SDK with the License Key
Initialize the Anyline Tire Tread SDK - and handle any exceptions thrown - before doing anything related to the SDK.
Here is an example on how to do it in Kotlin:
// This must be called before doing anything else with the AnylineTireTreadSdk.
// It only needs to be called once during your application life-cycle.
fun initializeAnylineTireTreadSdk() {
val licenseKey = "<your-license-key>"
// Try/Catch this to check if your license key is valid or not.
try {
AnylineTireTreadSdk.init(licenseKey, this)
// continue the setup after successful initialization
} catch (e: SdkLicenseKeyInvalidException){
// handle license key invalid exception
} catch (e: SdkInitializeFailedException){
// handle failed SDK initialisation
}
}
In the code above, replace <your-license-key> with your actual license key.
|
This function attempts to initialize AnylineTireTreadSdk
with the provided license key. If the SDK fails to initialize, you should handle this error appropriately.
Add the necessary permissions and features
The TireTreadScanView requires the following permissions and features on your application:
-
Permissions
-
CAMERA
-
INTERNET
-
VIBRATE
-
-
Features
-
android.hardware.camera
-
android.hardware.camera.flash
-
android.hardware.camera.autofocus
-
Here is an example on how you can add them to your AndroidManifest.xml
file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<!-- declare camera, internet, and vibrate permission -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="true" />
<uses-feature android:name="android.hardware.camera.flash" android:required="false" />
...
</manifest>
The Anyline Tire Tread SDK uses the camera for scanning the tires - your application must request the user’s permission to access the camera before using the TireTreadScanView .
Please refer to the Official Android Documentation for more information about requesting runtime permissions, and/or check our example implementation on GitHub.
|
In the next section, you will learn how to integrate the TireTreadScanView
to start scanning and measuring tires with your application.