Skip to main content

setup-android-wallet-sdk

Requirements​

  • Android 9+ (API level 28+)
  • Android Studio
  • Kotlin

Prerequisites​

  • Create an application to obtain a base URL. The SDK uses this base URL to interact with the LoginID authentication service.
  • Create an API key with at least the external:verify scope. You’ll need this to request authorization tokens from your backend.

Before installing the SDK, configure the association between your Android application and your website using a Digital Asset Links file.

Android uses a Digital Asset Links file named assetlinks.json to verify the association between your application and your website.

Find Your Package Name​

You can find your application's package name in the app module's build.gradle.kts file under defaultConfig:

android {
defaultConfig {
applicationId = "<PACKAGE_NAME>"
}
}

Generate the SHA-256 Certificate Fingerprint​

Use the keytool utility included with the Java Development Kit to retrieve the SHA-256 fingerprint of your application's signing certificate:

keytool -list -v \
-keystore KEYSTORE_PATH \
-alias KEYSTORE_ALIAS \
-storepass KEYSTORE_PASSWORD \
-keypass KEY_PASSWORD

Replace the following values:

  • KEYSTORE_PATH with the path to your keystore
  • KEYSTORE_ALIAS with the signing-key alias
  • KEYSTORE_PASSWORD with the keystore password
  • KEY_PASSWORD with the signing-key password

The command output includes the certificate's SHA-256 fingerprint.

Local Development

For local development, you can use the default Android debug keystore with the following values:

  • KEYSTORE_ALIAS: androiddebugkey
  • KEYSTORE_PASSWORD: android
  • KEY_PASSWORD: android

Use a dedicated signing key for production applications. For applications distributed through Google Play, you can find the app-signing certificate fingerprint in the Google Play Console.

Register the Fingerprint​

Register your application's SHA-256 certificate fingerprint in your LoginID application's FIDO2 section before continuing. For instructions, see Adding Android Fingerprint.

Host the assetlinks.json File​

Create an assetlinks.json file containing your application's package name and SHA-256 certificate fingerprint:

[
{
"relation": [
"delegate_permission/common.get_login_creds"
],
"target": {
"namespace": "android_app",
"package_name": "<PACKAGE_NAME>",
"sha256_cert_fingerprints": [
"<SHA256_FINGERPRINT>"
]
}
}
]

Replace <PACKAGE_NAME> and <SHA256_FINGERPRINT> with your application's values.

Host the file at the following location:

https://<WEBSITE_DOMAIN>/.well-known/assetlinks.json

The file must be publicly accessible over HTTPS.

Declare the Association in Your Android Application​

Add an asset_statements resource to res/values/strings.xml:

<resources>
<string name="asset_statements" translatable="false">
[{
\"include\": \"https://<WEBSITE_DOMAIN>/.well-known/assetlinks.json\"
}]
</string>
</resources>

Then add the corresponding <meta-data> element inside the <application> element of your AndroidManifest.xml file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<meta-data
android:name="asset_statements"
android:resource="@string/asset_statements" />
</application>
</manifest>

Set Up the SDK​

Add the SDK dependency​

First, ensure you have the Maven Central repository in your project's settings.gradle.kts file:

dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
}

Next, add the SDK and required dependencies to your app module's build.gradle.kts:

dependencies {
// LoginID SDK
implementation("io.loginid:undefined:1.0.1")
}

Initialize the SDK​

import io.loginid.LoginIDAuth

class MyApplication : Application() {
val lid = LoginIDAuth(<LOGINID_BASE_URL>)

override fun onCreate() {
super.onCreate()

// Additional setup...
}
}
info

You can view the source code here.