Skip to main content

Integration Guide for DreisamSDK (Android Standard)

This document serves as the standard integration guide for the DreisamSDK on the Android platform. It assumes that readers are already familiar with the basic usage of Android Studio and possess a certain level of Android programming knowledge.

Demo Download

  • Demo Folder: Contains a complete Android project that demonstrates the basic usage of the SDK, which can be used as a reference.
  • libs Folder: Includes the DreisamLib library file.

Android SDK Version Compatibility

Currently, the SDK only supports Android 8.0 (API Level 26) or higher.

Project Configuration and Integration Steps

  1. Unzip the integration package DreisamDemo V X.X.X.rar.
  2. Copy the file libs/DreisamLib-release_xxx.aar to the libs/ directory of your project. See the figure below for reference.
Image
  1. Modify the dependencies block in your project configuration file Add the line: implementation(files("libs/DreisamLib-release_1.0.1_2512311723.aar")) Refer to the figure below for details. A34c0691 4a08 417f 9a1d 43ad7a8a5d32

Full build.gradle Configuration File

plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
    id("org.jetbrains.kotlin.kapt")
}

android {
    namespace = "com.dreisamlib.demo"
    compileSdk = 35

    defaultConfig {
        applicationId = "com.dreisam.demo"
        minSdk = 26
        targetSdk = 36
        versionCode = 1
        versionName = "1.0"
    }
  
    buildTypes {
        release {
            isShrinkResources = true // Whether resource shrinking is enabled
            isMinifyEnabled = true // Whether code obfuscation is enabled
            isDebuggable = false // Whether the build is debuggable
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
        debug {
            isShrinkResources = false // Whether resource shrinking is enabled
            isMinifyEnabled = false // Whether code obfuscation is enabled
            isDebuggable = true // Whether the build is debuggable
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }
}

dependencies {
    implementation(files("libs/DreisamLib-release_1.0.1_2512311723.aar"))

    implementation("androidx.activity:activity:1.8.0")
    implementation("androidx.core:core-ktx:1.8.0")
    implementation("androidx.appcompat:appcompat:1.6.1")
    implementation("com.google.android.material:material:1.8.0")
    implementation("androidx.constraintlayout:constraintlayout:2.1.4")

    // Gson
    implementation("com.google.code.gson:gson:2.13.2")
    implementation("me.dm7.barcodescanner:zxing:1.9.4")

    // Dynamic Permission Framework - XXPermissions
    implementation("com.github.getActivity:XXPermissions:26.0")
    // Room (Local Database)
    implementation("androidx.room:room-runtime:2.6.1")
    implementation("androidx.room:room-ktx:2.6.1")
    kapt("androidx.room:room-compiler:2.6.1")
}

Add Basic Permissions

Add the following permissions to your AndroidManifest.xml file:
<uses-permission
    android:name="android.permission.BLUETOOTH"/> <!-- Bluetooth connection -->
<uses-permission
    android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- Bluetooth scanning -->
<!-- ************************ Location Permissions (Required for Bluetooth Scanning on Android 11 and Below) ********************-->
<uses-permission
    android:name="android.permission.ACCESS_FINE_LOCATION"/> <!-- Precise location (required for all versions) -->
<uses-permission
    android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- Coarse location -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <!-- Background location -->
<!-- ************************ Bluetooth Permissions (Android 12 and Above) ********************-->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
    android:usesPermissionFlags="neverForLocation" /><!-- Bluetooth scanning -->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> <!-- Bluetooth connection -->

ProGuard Configuration

Add the following rules to your ProGuard configuration file (proguard-rules.pro):
-keep class  com.dreisamlib.lib.* {*;}