1
0 Comments

Building a Chat App for Android from Scratch –Complete Guide

Requirements To Build Chat Application Android

The utmost minimal requirement you need for your Chat SDK for Android is as follows,

Android Lollipop 5.0 (API Level 21)
Java 7 or higher
Gradle 4.1.0 or higher
SDK License Key
Authentication of SDK is the core process of initialization, where the CONTUS MirrorFly performs at it’s server end using the License key. Moreover, to be very assured you can make use of this license key in your dashboard too while generating an account.

Everything is fine, but do keep in mind that these master API tokens can never be revoked or changed once done with the process.

MirrorFly Chat SDK Installation Into Your Android Chat App
Installation process is the basic one to start with but before that you have to make sure that whether the SDKs have already been compiled into an AAR file or not? This is because, if you want to use the SDKs then the below AAR files need to be imported into the project. Although, you need the support of Kotlin for messaging SDKs to proceed further in the project.

Step 1 – To begin with you have to download the latest SDK from CONTUS MirrorFly Control Panel Download’s section

Step 2 – Time To Extract The Required File From The Download Zip Folder
Step 3 – Now, Create A New Android Project And Assign A Name
Step 4 – Do Add The Libraries Into The Apps/Libs Folder Available In The Project,

appbase.aar
flycommons.aar
flynetwork.aar
flydatabase.aar
compression.aar
xmpp.aar
Step 5 – Add The Below Given Dependencies In App/Build.Gradle File
implementation files('libs/appbase.aar')
implementation files('libs/flycommons.aar')
implementation files('libs/flynetwork.aar')
implementation files('libs/flydatabase.aar')
implementation files('libs/compression.aar')
implementation files('libs/xmpp.aar')
Step 6 – Add The Below Statements Of Dependencies By The SDK In App/Build.Gradle
//For lifecycle listener
implementation 'android.arch.lifecycle:extensions:1.1.1'
annotationProcessor 'android.arch.lifecycle:compiler:1.1.1'

//For GreenDao
implementation 'de.greenrobot:greendao:2.1.0'

//For gson parsing
implementation 'com.google.code.gson:gson:2.8.1'

//for smack implementation
implementation 'org.igniterealtime.smack:smack-android:4.2.4'
implementation 'org.igniterealtime.smack:smack-tcp:4.2.4'
implementation 'org.igniterealtime.smack:smack-im:4.2.4'
implementation 'org.igniterealtime.smack:smack-extensions:4.2.4'
implementation 'org.igniterealtime.smack:smack-sasl-provided:4.2.4'

implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.android.gms:play-services-location:17.0.0'

implementation 'com.facebook.stetho:stetho:1.3.1'
implementation 'com.hypertrack:hyperlog:0.0.10'

//for mobile number formatting
implementation 'io.michaelrocks:libphonenumber-android:8.9.14'

//Dagger Dependencies
api 'com.google.dagger:dagger:2.25.2'
kapt 'com.google.dagger:dagger-compiler:2.25.2'
api 'com.google.dagger:dagger-android:2.25.2'
api 'com.google.dagger:dagger-android-support:2.25.2'
kapt 'com.google.dagger:dagger-android-processor:2.25.2'

//coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.3'

//apicalls
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
implementation 'com.squareup.okhttp3:okhttp:4.2.0'
implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'

//stetho interceptor
implementation 'com.facebook.stetho:stetho-okhttp3:1.3.1'

//okhttp interceptor
implementation 'com.squareup.okhttp3:logging-interceptor:3.14.3'
Step 7 – Add The Below Statements Of Dependencies By The SDK In App/Build.Gradle
plugins {
...
id 'kotlin-android'
id 'kotlin-kapt'
}

android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
    jvmTarget = '1.8'
}

packagingOptions {
    exclude 'META-INF/AL2.0'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/LGPL2.1'
    exclude("META-INF/*.kotlin_module")
}

}
Step 8 – Now, Open The AndroidManifest.XML And Add The Below Provided Permissions To Proceed Further With The Development Process.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

These are the technical steps that are required to have the best chat app.

Explore full article here : https://blog.contus.com/build-a-android-chat-app/

on March 9, 2022