# Android

## <mark style="color:purple;">Gradle Installation</mark>

### Prerequisite

SDK supports Android 5.0 (API Level 21) and above

```gradle
android {
    ...
    defaultConfig {
        minSDKVersion 21 // at least 21
    }
}
```

### Installation

Add the Jitpack repository in your project level `build.grade` at the end of repositories:

```gradle
allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}
```

Add the dependency in your module level `build.grade.` Find latest UIKit version at [Changelog](https://docs.social.plus/social-plus-uikit/changelogs/changelog-1).

```gradle
// add buildFeatures, compileOptions and kotlinOptions in android tag
android {

    buildFeatures {
        dataBinding = true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8
    }

}

dependency {
implementation 'com.github.AmityCo.Amity-Social-Cloud-UIKit-Android:amity-uikit:x.y.z'
}
```

### Managing Conflicting File Generation

In your app module's `build.gradle` , add the following packaging options.

```kotlin
android {
    ...
    packagingOptions {
        exclude 'META-INF/INDEX.LIST'
        exclude 'META-INF/io.netty.versions.properties'
    }
}
```

***

## <mark style="color:purple;">Open-source Installation</mark>

With open source, developers have more flexibility and greater customization options, allowing you to have complete control over the visual style. Open sourcing allows for more transparency and visibility, and enables contributions from a greater developer community in terms of good design, implementation, code improvement, and fixes, translating into a better product and development experience.

### Migrate Android Open Source UI Kit with Existing Project

#### Remove existing gradle dependency

If you've never used UI Kit from a gradle dependency before, you may skip this step and proceed to the next step. If you are migrating the UIKit with an existing gradle dependency, you will need to remove it from the gradle at the application level.

```
implementation 'com.github.AmityCo.Amity-Social-Cloud-UIKit-Android:amity-uikit:x.y.z'
```

#### Import UI Kit module to your existing project

* Clone or download source code from an open-source Github repository. <https://github.com/AmityCo/Amity-Social-Cloud-UIKit-Android-OpenSource>

![](https://2352509137-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX0mOAVWkotGme0iRzu%2Fuploads%2FhDW9rC0oIGhw2mUnGRMt%2Fimage.png?alt=media\&token=76890aca-4c9e-4aa7-ad66-84d1365fa249)

* Navigate to your current application in Android Studio, then at the top navigation bar go to **File > New > Import Module...**

![](https://2352509137-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX0mOAVWkotGme0iRzu%2Fuploads%2FD5LxmoS8Ue0GyZp9eViM%2Fimage.png?alt=media\&token=2f9b649b-8f93-45e4-87aa-422150245558)

* Choose the source directory where you downloaded/cloned UI Kit source code.

![](https://2352509137-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX0mOAVWkotGme0iRzu%2Fuploads%2FX2F1eRs4gRREZfVNOZMc%2Fimage.png?alt=media\&token=31a7b1d7-7ad7-4282-9a6c-940dbfa6586b)

* Make sure that you import `:chat` , `:common`, `:social`, and `:amity-uikit` module as per the screenshot described. The `:sample` module is optional and solely contains examples of UIKit Fragments and Activities.

![](https://2352509137-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX0mOAVWkotGme0iRzu%2Fuploads%2F42pVAcspV2IbOY5LEOB1%2Fimage.png?alt=media\&token=5578ca6a-19de-41ea-a31d-bb24b102ab44)

* Navigate to the root project's `settings.gradle` file once the modules have been successfully imported. You may see that Android Studio generated a dependency path from the UI Kit source code directory you specified initially. However, there's a chance that Android Studio won't do so or may generate the incorrect path. Please double-check that the path is accurate.

![](https://2352509137-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX0mOAVWkotGme0iRzu%2Fuploads%2Fs787qYbx9nM5XGDy2xcY%2Fimage.png?alt=media\&token=9474b798-a66f-45b1-9558-6345a38dbe7d)

* Additionally, in the root project's `settings.gradle` it's also mandatory to declare jitpack.io repository destination by adding `maven { url https://jitpack.io }` to **dependencyResolutionManagement > repositories**.

![](https://2352509137-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX0mOAVWkotGme0iRzu%2Fuploads%2Fwifa0t4liiWdVgpmSrAo%2Fimage.png?alt=media\&token=d31561a9-1b29-4233-bf27-e8c51002b4ec)

* Add the imported module to application's gradle file by adding:

```
implementation project(path: ':amity-uikit')
```

![](https://2352509137-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX0mOAVWkotGme0iRzu%2Fuploads%2Ff5qaUwcRDgSYFyptwjHE%2Fimage.png?alt=media\&token=23b9d08c-d796-4ca8-8f1c-78a653f6cab3)

* Exclude these META-INF from the packaging options in application's gradle

```
 packagingOptions {
        exclude 'META-INF/INDEX.LIST'
        exclude 'META-INF/io.netty.versions.properties'
    }
```

* Lastly, apply this in the `project-level` build.gradle file. `apply from: "../Amity-Social-Cloud-UIKit-Android/buildsystem/dependencies.gradle"`

![](https://2352509137-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX0mOAVWkotGme0iRzu%2Fuploads%2FHa3vFhqvZdmwclY9fiUn%2Fimage.png?alt=media\&token=3bda2e45-0ab1-4cf4-a93a-d950db3f6bd4)

{% hint style="info" %}
Also make sure that your settings `android.nonTransitiveRClass=false` in `gradle.properties` file
{% endhint %}

Woohoo! All set now you're ready to explore and modify our UI Kit in your application project.

<figure><img src="https://2352509137-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX0mOAVWkotGme0iRzu%2Fuploads%2Fqh7FPcYJTtYwTrVJVW5s%2FScreenshot%202566-02-22%20at%2007.07.54.png?alt=media&#x26;token=25c20c09-1c62-4e73-a778-b7a753a2043a" alt=""><figcaption></figcaption></figure>

### Modifying Android Open Source UI Kit

You can modify the Android open source UI Kit to customize behaviors to fit your needs. To modify the code, simply copy and paste it into your local machine.

We recommend that you first fork the repository before starting any customization work, so that it will be easier to merge the code with the next version update that we provide from the main repository.

Reference on forking: <https://docs.github.com/en/get-started/quickstart/fork-a-repo>

### Get Latest Open Source UI Kit Updates

To update to the latest version of the UI Kit, you can pull the latest commit of the git submodule.

```
cd Amity-Social-Cloud-UIKit-Android-OpenSource
git pull origin master
git checkout tags/4.0.0-beta01
cd ..
git add .
git commit -m “Update android uikit opensource submodule”
git push origin branch_name
```
