Integración
[en] In the integration process for Android native apps, you need to:
[en] Access the necessary resources;
[en] configure build.gradle and dependencies;
[en] modify the manifest; and
[en] sync Gradle files
[en] Access Resources
[en] To access the necessary resources to install XpressPlug for Android native apps, you have to add the following code to the build.gradle file in your Android project, within the React project:
allprojects { repositories { maven { url "https://developer.veritran.com/resources/api/v4/groups/10/-/packages/maven" name "GitLab" credentials(HttpHeaderCredentials) { name = 'Private-Token' value = '<PRIVATE_TOKEN>' } authentication { header(HttpHeaderAuthentication) } } }
Importante
[en] To obtain the private token, send an email to mobile_support@veritran.com with the "XpressPlug Access" assignment, and the team will provide you with the necessary resources.
[en] Configure build.gradle and dependencies
[en] Next, you need to add XpressPlug as a dependency to the current project, with any other dependencies needed. Follow these steps:
[en] Add the following lines to the build.gradle (module) file on you Android project to install the artifacts that are necessary to integrate XpressPlug.
//Veritran dependencies implementation 'com.veritran:ui:7.9.1.49455' implementation 'com.veritran:ui_interfaces:7.9.1.49455' implementation 'com.veritran:xpressplug:7.9.1.49455' //Third party dependencies implementation 'androidx.constraintlayout:constraintlayout:2.1.3' implementation 'com.karumi:dexter:6.2.1' implementation 'org.nanohttpd:nanohttpd-webserver:2.3.1' implementation 'com.scottyab:rootbeer-lib:0.0.8' implementation 'androidx.core:core:1.3.0' implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.fragment:fragment:1.1.0' implementation 'com.google.android.gms:play-services-basement:17.0.0' implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.0' implementation 'com.google.code.gson:gson:2.10.1' implementation 'com.google.guava:guava:31.1-android' implementation 'com.madgag.spongycastle:core:1.54.0.0' implementation 'com.madgag.spongycastle:prov:1.54.0.0' implementation 'com.madgag.spongycastle:pkix:1.54.0.0' implementation 'org.apache.commons:commons-text:1.2' implementation 'androidx.recyclerview:recyclerview:1.1.0' implementation 'com.squareup.duktape:duktape-android:1.3.0' implementation 'com.squareup.okhttp3:okhttp:3.12.13' implementation 'com.facebook.soloader:soloader:0.10.3' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'org.conscrypt:conscrypt-android:2.5.2' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'androidx.security:security-crypto:1.0.0' implementation 'com.airbnb.android:lottie:3.0.7'
[en] Enable Kotlin for the project by adding the following dependency to the build.gradle project:
buildscript { ... dependencies { ... classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0" ... } ... }
[en] Add the following to the beginning of the build.gradle module:
apply plugin: 'kotlin-android'
[en] Modify the Manifest
[en] Then, you need to modify the AndroidManifest.xml in your Android project. See the example below:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.reactxpressplugexample"> <application android:allowBackup="false" android:fullBackupContent="false" tools:replace="android:allowBackup,android:fullBackupContent,android:label"> <uses-library android:name="org.apache.http.legacy" android:required="false" /> </application> </manifest>
Nota
[en] See Android's developer documentation for more information about allowBackup, fullBackupContent and httpLegacy.
[en] Sync Gradle Files
[en] Lastly, you need to sync gradle files. To do this, go to Android Studio, and go to File > Sync Project with Gradle Files. You can also type the following command on your terminal:
./gradlew --refresh-dependencies