On This Page
Configuring the Tap to Pay on Android SDK
Use the information in this section to configure the Tap to Pay on Android SDK.
Configure the Project settings.gradle File
settings.gradle
FileFollow this step to configure your project's
settings.gradle
file.- Add the repository to your project'ssettings.gradlefile.dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { mavenCentral() google() exclusiveContent { forRepository { maven { setUrl("https://repo.visa.com/mpos-releases/") } } filter { includeGroup("io.payworks") } } } }
Configure the Project build.gradle File
build.gradle
FileFollow this step to configure your project's
build.gradle
file.- Add the Kotlin Gradle plug-in, which is required to use this solution. Note that Kotlin version 2.1 or later and Android Gradle version 8.2 or later are required.plugins { id("com.android.application") version "8.2.0" apply false id("org.jetbrains.kotlin.android") version "2.1.0" apply false }
Configure the Module build.gradle File
build.gradle
FileFollow these steps to configure your module
build.gradle
file.- In the Android section, add these exclusion rules to your module'sbuild.gradlefile.android { ... packaging { resources { excludes.add("META-INF/*") excludes.add("LICENSE.txt") excludes.add("asm-license.txt") } } }
- In order for the app to support Java 17 features, you must set the compatibility levels.android { ... compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { jvmTarget = "17" } }
- The Tap to Pay on Android Solution library publishes a release build type only. The debug build type is not available, so set thematchingFallbacksfield value torelease.android { ... buildTypes { ... debug { matchingFallbacks.apply { clear() add("release") } } } }
- IMPORTANTStay current with the latest SDK. The SDK repository is continuously updated to make available the six latest versions. When a new version is released, the oldest is removed and can no longer be used for new application builds. Establish a regular process for updating to the newest available SDK version to avoid potential build failures and to ensure that your application runs with the latest features, performance enhancements, and security updates.Add the required Default UI and Tap to Pay on Android libraries to the Dependencies section of your module'sbuild.gradlefile.dependencies { ... // This is the Default UI dependency implementation("io.payworks:paybutton-android:2.113.0") // This is the Tap to Pay dependency implementation("io.payworks:mpos.android.taptophone:2.113.0") }
Update the AndroidManifest.xml File
AndroidManifest.xml
FileTo support a large heap size and ensure the necessary permissions for the Default
UI, update your Follow these steps to update your
AndroidManifest.xml
file. Enabling a larger heap is
essential for scenarios where terminal updates require the handling and transfer of
large volumes of data.WARNING
Do not enable automatic backup in your app's
AndroidManifest
file. The Tap to Pay on Android SDK uses the Android
Keystore to install and store cryptographic keys in your app. Using automatic backup
restores the default encryption preferences and causes a functionality error in the
Tap to Pay on Android SDK.AndroidManifest.xml
file:- Set theandroid:allowBackupattribute tofalseand theandroid:largeHeapattribute totrue.<application ... android:allowBackup="false" android:largeHeap="true" > ... </application>
- Enable the needed permissions for the Default UI.<manifest ... > ... <!-- Needed for Default UI ! --> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> ... </manifest>
Configure ProGuard Rules to Enable Obfuscation
Follow these steps to configure ProGuard rules that enable obfuscation.
- To enable obfuscation for any of your build types, define the setting in the relevantbuild.gradlefile for your app.buildTypes { release { isMinifyEnabled = true proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") } }
- If you are using ProGuard as an obfuscation tool in your app, add these rules to theproguard-rules.profile.# OkHttp -keepattributes Signature -keepattributes *Annotation* -dontwarn com.squareup.okhttp.** -keep class com.squareup.okhttp.* { *; } -dontwarn okio.** # Acceptance Devices -keep class io.mpos.** { *; } -dontwarn io.mpos.** -keep class com.visa.vac.tc.** {*;} -keep class com.nimbusds.jose.** {*;} -keep class org.bouncycastle.** {*;} -keep class retrofit2.** { *; } -keep interface retrofit2.** { *; } -keep class com.visa.auth.** { *; } -dontwarn com.visa.auth.** -keep class androidx.** { *; } # Visa Sensory Branding -keep class com.visa.SensoryBrandingView # Mastercard Sonic Branding -keep class com.mastercard.sonic.BuildConfig {*;}