# 4. Integrate Bayun SDK

### 4.1 Bayun SDK integration in the Project

* Create a folder named `Bayun` in your project and add the `Bayun.aar` file.

```xml
dependencies {
    implementation files('<Path-of-aar-file>')  //implementation files('../Bayun/Bayun.aar')
}
```

* The Bayun SDK requires some dependencies that couldn't be included in the archive itself. For the SDK to work, these dependencies must be added by the app implementing the Bayun SDK. In the "build.gradle" file of the "app" module of your application, add the following code.

```groovy
dependencies {
....
    implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.10.1'
    implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.10.1'
    implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.10.1'
    implementation 'com.github.tony19:logback-android:2.0.0'
    implementation 'androidx.biometric:biometric:1.0.1'
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.okhttp3:okhttp:4.9.3'
    implementation 'org.slf4j:slf4j-api:1.7.30'
    implementation 'com.yakivmospan:scytale:1.0.1'

}
```

* If your application uses Java and not Kotlin, you might need to also add another dependency that will form a bridge between the Kotlin dependencies of the SDK and your Java code.

```groovy
dependencies {
    ....
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.61"
}
```

* If your application uses Java and  Kotlin, you might need to also add `:Bayun` in `setting.gradle` file

```xml
include ':app', ':Bayun'
```

### 4.2 AndroidManifest.xml

* The Bayun Android SDK requires some permissions and references from your app’s AndroidManifest.xml file. These permissions allow the SDK to monitor network state.

```groovy
<!-- Standard permissions -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
```

* The Bayun Android SDK contains a service and an activity that must be declared in your app's AndroidManifest.xml file under `<application/>` section, for it to work.

```groovy
<!-- Declare Bayun SDK's background service -->
<service android:name="com.bayun_module.BayunBackgroundService"/>
<!-- Declare Bayun SDK's background activity for screen locks -->
<activity android:name="com.bayun_module.EmptyActivity"/>

```
