Skip to main content

Android SDK Installation

Get started with the DoorstepAI Android SDK to add intelligent delivery tracking to your Android application.

Prerequisites

Before you begin, ensure you have:

  • Android Studio (latest stable version recommended)
  • Minimum SDK version: Android API level 21 (Android 5.0)
  • Target SDK version: Android API level 33+ (Android 13+)
  • Valid API Key from DoorstepAI
  • Kotlin or Java development environment
Development Environment

We recommend using Android Studio with the latest Android Gradle Plugin for the best development experience and access to the latest Android features.

Installation

Add SDK Dependency

Add the DoorstepAI Android SDK to your module-level build.gradle file (usually app/build.gradle):

app/build.gradle
dependencies {
implementation 'ai.doorstep.com:doorstepai-dropoff-sdk:1.0.13'

// Other dependencies...
}

Sync Project

After adding the dependency, sync your project:

  1. Click "Sync Now" in the notification bar, or
  2. Go to File → Sync Project with Gradle Files

Android Manifest Configuration

Required Permissions

Add the following permissions to your AndroidManifest.xml file outside the <application> tag:

AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourapp.package">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

<application>
<!-- Your app components -->
</application>
</manifest>

Hardware Features

Add the following hardware feature declarations to your AndroidManifest.xml:

AndroidManifest.xml
<uses-feature android:name="android.hardware.sensor.accelerometer" />
<uses-feature android:name="android.hardware.sensor.gyroscope" />
<uses-feature android:name="android.hardware.sensor.barometer" />
<uses-feature android:name="android.hardware.sensor.compass" />
<uses-feature android:name="android.hardware.sensor.proximity" />

Permission Details

PermissionPurposeRequiredRuntime
INTERNETNetwork communicationRequiredNo
ACCESS_FINE_LOCATIONPrecise location trackingRequiredYes
ACCESS_COARSE_LOCATIONApproximate locationRequiredYes
ACCESS_BACKGROUND_LOCATIONBackground location accessRequiredYes
ACTIVITY_RECOGNITIONMotion and activity detectionRequiredYes
FOREGROUND_SERVICEBackground processingRequiredNo
FOREGROUND_SERVICE_LOCATIONLocation foreground serviceRequiredNo
FOREGROUND_SERVICE_DATA_SYNCData sync foreground serviceRequiredNo
POST_NOTIFICATIONSDelivery notificationsRequiredYes (API 33+)
WAKE_LOCKKeep device awake during trackingRequiredNo
ACCESS_WIFI_STATEWiFi state accessRequiredNo
ACCESS_NETWORK_STATENetwork state accessRequiredNo
Notification Permission (Android 13+)

Starting with Android 13 (API level 33), apps must request the POST_NOTIFICATIONS permission at runtime.

Permission Utilities

The SDK provides a utility class to help manage required permissions. Copy this class into your app:

DoorstepAIPermissionUtils.kt
import android.Manifest
import android.content.Context
import android.content.pm.PackageManager
import android.os.Build
import androidx.core.content.ContextCompat

/**
* DoorstepAI SDK Permission Utilities
*
* This class provides utilities for handling permissions required by the DoorstepAI SDK.
* This is needed as certain permissions need runtime approval
* Copy this entire class into your app to handle SDK permissions.
*/
object DoorstepAIPermissionUtils {

fun getRequiredPermissions(): List<String> {
val permissions = mutableListOf(
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_NETWORK_STATE
)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
permissions.add(Manifest.permission.ACTIVITY_RECOGNITION)
permissions.add(Manifest.permission.ACCESS_BACKGROUND_LOCATION)
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
permissions.add(Manifest.permission.FOREGROUND_SERVICE)
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
permissions.add(Manifest.permission.POST_NOTIFICATIONS)
}

return permissions
}

fun hasAllPermissions(context: Context): Boolean {
return getRequiredPermissions().all { permission ->
ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED
}
}

fun getMissingPermissions(context: Context): List<String> {
return getRequiredPermissions().filter { permission ->
ContextCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED
}
}

/**
* Get permission rationale text for showing to users
* @return User-friendly explanation of why permissions are needed
*/
fun getPermissionRationale(): String {
return "The DoorstepAI SDK needs these permissions"
}
}

Verification

To verify the installation was successful:

  1. Build your project (Build → Rebuild Project)
  2. Check for import errors in files using DoorstepAI SDK classes
  3. Verify permissions are properly declared in your AndroidManifest.xml

Import Test

Try importing the SDK in your Application or Activity and Initializing the SDK:

MainActivity.kt
import com.doorstepai.sdks.tracking.DoorstepAI

class MainActivity : ComponentActivity() {
companion object {
private const val FIXED_API_TOKEN = "your_api_key_here" // Replace with your actual API token
}

private var permissionsGranted by mutableStateOf(false)
private var sdkInitialized by mutableStateOf(false)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
checkPermissionsAndInitialize()
}

fun checkPermissionsAndInitialize() {
if (DoorstepAIPermissionUtils.hasAllPermissions(this)) {
permissionsGranted = true
initializeSDK()
} else {
permissionsGranted = false
}
}

private fun initializeSDK() {
try {
DoorstepAI.init(this) { result ->
result.fold(
onSuccess = {
try {
DoorstepAI.setAPIKey(FIXED_API_TOKEN)
println("✅ DoorstepAI SDK initialized successfully + API token set")
sdkInitialized = true
} catch (e: Exception) {
println("❌ Failed to set API token: ${e.message}")
sdkInitialized = false
}
},
onFailure = { error ->
println("❌ SDK initialization failed: ${error.message}")
sdkInitialized = false
}
)
}
} catch (e: Exception) {
println("❌ Error during SDK initialization: ${e.message}")
sdkInitialized = false
}
}
}
Android 13+ Requirements

As of Android 13 and above, make sure to handle the new POST_NOTIFICATIONS runtime permission. Users must explicitly grant notification permission for the SDK to show delivery tracking notifications.

Troubleshooting Installation

Common Issues

Build Errors

  • Error: "Could not resolve dependency"
    • Solution: Check internet connection and verify the repository URL
    • Solution: Ensure you're using the correct version number

Manifest Merge Conflicts

  • Error: "Manifest merger failed"
    • Solution: Check for duplicate permission declarations
    • Solution: Use tools:replace for conflicting attributes

Permission Issues

  • Error: App crashes on launch or Start Delivery Failed
    • Solution: Verify all required permissions are in AndroidManifest.xml
    • Solution: Check runtime permission handling for API 23+

Getting Help

If you encounter issues during installation:

  1. Check our troubleshooting guide
  2. Review the Android integration examples
  3. Contact our support team at support@doorstep.ai

Next Steps

Now that you have the SDK installed and configured:

  1. 📚 Learn SDK Usage - Initialize and use the SDK
  2. 💡 View Examples - See complete implementation examples
Ready to Implement?

Head over to our Usage Guide to learn how to implement the SDK and start using delivery tracking in your Android app.