# Android SDK Setup

## 1. Requirements

* [Sign up](https://console.flarelane.com) to FlareLane and create a project

***

## 2. Credentials Setup

Follow this guide below:

* [android-fcm-setup-v1](https://guide.flarelane.com/guide-for-developers/mobile-sdk-setup/additional-setup/android-fcm-setup-v1 "mention")

***

## 3. Install SDK using Gradle

Add the Gradle repository. Enter the following values ​​inside the repositories block:

{% hint style="info" %}
**Where is the repositories block in your project?**<br>

For a project created through the latest Android Studio, it is located in settings.gradle -> dependencyResolutionManagement.

For others, build.gradle -> allprojects.
{% endhint %}

{% tabs %}
{% tab title="settings.gradle" %}

<pre class="language-gradle"><code class="lang-gradle">dependencyResolutionManagement {
  repositories {
    // Add the code below
<strong>    maven { url 'https://jitpack.io' }
</strong>  }
}
</code></pre>

{% endtab %}

{% tab title="build.gradle (legacy)" %}

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

{% endtab %}
{% endtabs %}

Open your App level build.gradle(\<project>/\<app>/build.gradle), add the SDK and click Sync Now to get up to date.

{% tabs %}
{% tab title="build.gradle" %}

<pre class="language-gradle"><code class="lang-gradle">dependencies {
  // Add the code below
<strong>  implementation 'com.github.flarelane:FlareLane-Android-SDK:1.8.3'
</strong>}
</code></pre>

{% endtab %}
{% endtabs %}

***

## 4. Initialization

{% hint style="info" %}
Add initialization code to onCreate of Application Class (not Activity). Start by creating an Application Class first, and if you already have an Application Class, you can skip this process.
{% endhint %}

Enter `android.name=".MainApplication"` in the AndroidManifest.xml file and generate the MainApplication class file through the editor helper. You can also create this file manually.

<figure><img src="https://4151189289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSJ35x4PFzaneH3SrvcBt%2Fuploads%2Fsdf6mOoHnY2cNXA5TMnY%2Fimage.png?alt=media&#x26;token=84f648c1-3279-4f10-9ac1-b0378baa5c36" alt=""><figcaption></figcaption></figure>

Add the following code to `onCreate`. You can check your project ID at FlareLane console's **Project**.

{% tabs %}
{% tab title="Kotlin (MainApplication.kt)" %}

<pre class="language-kotlin"><code class="lang-kotlin">import com.flarelane.FlareLane

class MainApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        
        // Add the code below
        // To subscribe later, set the 3rd parameter to false and then run the .subscribe() later.
<strong>        FlareLane.initWithContext(this, "INPUT_YOUR_PROJECT_ID", true)
</strong>    }
}
</code></pre>

{% endtab %}

{% tab title="Java (MainApplication.java)" %}

```java
import com.flarelane.FlareLane;

public class MainApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        
        // Add the code below
        // To subscribe later, set the 3rd parameter to false and then run the .subscribe() later
        FlareLane.initWithContext(this, "INPUT_YOUR_PROJECT_ID", true);
    }
}
```

{% endtab %}
{% endtabs %}

***

## 5. Test

After completing all the steps, build and run your app. Devices that subscribe to push notifications will be automatically added to FlareLane console's **All Devices**.

Before actual deployment, be sure to verify that the push notifications are being received properly on the device and that the statistics are accurately recorded when the push notifications are clicked.

***

## 6. Identify your user

FlareLane's device is 'anonymous' and you can match the device with your user based on the unique user ID that identifies your user.

{% hint style="info" %}
Setting up [User ID](https://guide.flarelane.com/data-integration/user-id) has many benefits. You can distinguish whether a user has signed-up, and push notifications can be sent based on the User ID.
{% endhint %}

Usually, when a user sign-up or log-in, you should execute `setUserId`.

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
FlareLane.setUserId(this, "USER_ID")
```

{% endtab %}

{% tab title="Java" %}

```java
FlareLane.setUserId(this, "USER_ID");
```

{% endtab %}
{% endtabs %}

***

## 7. Additional Setup

To set a accent color or channel name, add the following lines:

{% tabs %}
{% tab title="values/strings.xml" %}

<pre class="language-xml"><code class="lang-xml">&#x3C;resources>
    &#x3C;!-- accent color  -->
<strong>    &#x3C;string name="flarelane_notification_accent_color">#BC0000&#x3C;/string>
</strong>    &#x3C;!-- channel name -->
<strong>    &#x3C;string name="flarelane_default_channel_name">All Notifications&#x3C;/string>
</strong>&#x3C;/resources>
</code></pre>

{% endtab %}
{% endtabs %}

To customize notification icons, see below:

* [android-notification-icons](https://guide.flarelane.com/guide-for-developers/mobile-sdk-setup/additional-setup/android-notification-icons "mention")

To use [Journeys](https://guide.flarelane.com/guide-for-developers/mobile-sdk-setup/broken-reference) or [Message Personalization](https://guide.flarelane.com/guide-for-developers/mobile-sdk-setup/broken-reference), integrate custom data via SDK or API:

* [data-integration](https://guide.flarelane.com/data-integration "mention")

***

## Resources

[mobile-sdk-reference](https://guide.flarelane.com/guide-for-developers/mobile-sdk-reference "mention")
