Skip to content

Latest commit

 

History

History
55 lines (41 loc) · 1.41 KB

add-an-application-class-to-you-android-application.md

File metadata and controls

55 lines (41 loc) · 1.41 KB
description
Detailed steps to add an Application class to initialize the RudderStack SDK

How to Add an Application Class to Your Android App

We recommend using a global Application class to initialize our SDK. If you don't have an Application class for your project, follow these steps:

  • Create a class that extends Application.

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

import android.app.Application

class MainApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        
        // initialize Rudder SDK here
    }
}

{% endtab %}

{% tab title="JAVA" %}

import android.app.Application;

public class MainApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        
        // initialize Rudder SDK here
    }
}

{% endtab %} {% endtabs %}

  • Open AndroidManifest.xml file of your app and locate <application> tag.
  • Add an attribute android:name and set it to your new application class.
<application
    android:name=".MainApplication"
    <!-- ... -->
</application>

Contact Us

In case of any queries, you can always contact us, or feel free to open an issue on our GitHub Issues page if you come across any error or discrepancy.