Setup Android

The AusweisApp SDK Wrapper for android is available as a maven package. To use it, make the following adjustments to your Gradle configuration:

  1. Make sure that the repositories section includes the governikus repository:

allprojects {
    [...]
    repositories {
        [...]
        maven { url 'https://nexus.governikus.de/nexus/content/repositories/SDKWrapper/' }
    }
}
  1. Add the library to the dependencies section:

implementation 'de.governikus.ausweisapp2:sdkwrapper:2.2.0'

App Bundle

The AusweisApp SDK Wrapper uses native libraries which need to be extracted when used in an App Bundle, otherwise the SDK will not work correctly.

Add the following statement to your app’s build.gradle file:

android {
    packagingOptions {
        jniLibs {
            useLegacyPackaging = true
        }
    }
}

Initialization of the Android Application

The integrated SDK used by the AusweisApp SDK Wrapper creates a fork of the Android “main” Application once started. Due to this, the Application is instantiated a second time. Thus, it must ensure that any initialization (e.g. Firebase connections) is only carried out once. To do so the following snippet may prove useful:

class MyAwesomeApp : Application() {
    private val AA2_PROCESS = "ausweisapp2_service"

    override fun onCreate() {
        super.onCreate()

        if (isAA2Process())
            return
    }

    private fun isAA2Process(): Boolean {
        if (Build.VERSION.SDK_INT >= 28) {
            return getProcessName().endsWith(AA2_PROCESS)
        }

        val pid = Process.myPid()
        val manager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
        for (appProcess in manager.runningAppProcesses) {
            if (appProcess.pid == pid) {
                return appProcess.processName.endsWith(AA2_PROCESS)
            }
        }
        return false
    }
}