Add Application Class to Initialize Android (Java) SDK

Add an Application class to initialize the RudderStack Android (Java) SDK.

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

  1. Create a class that extends Application.
kotlin
class MainApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        // initialize Rudder SDK here
    }
}
  1. Open AndroidManifest.xml file of your app and locate <application> tag.
  2. Add an attribute android:name and set it to your new application class.
xml
<application
    android:name=".MainApplication"
    <!-- ... -->
</application>

Questions? Let's figure it out together.

Join the RudderStack Slack community to connect with other users, customers, and the RudderStack team — or reach out for direct support.