AndroidManifest settings for previous SDK versions and jar

If you choose to use a .jar file, or want to run an older version of our Android SDK (prior to 2.1.0), then you'll need to fully edit your manifest file to include all the necessary services and receivers.

Follow the setup steps listed here, but for Step 3, be sure to edit your manifest to match the example below, with services for FCM or GCM, depending on your setup.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="[com.YOUR_PACKAGE]"
    android:versionCode="1"
    android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="9" />
<!-- Base permissions for Leanplum Android SDK. -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>

<!-- These permissions are required only for push notifications. -->

<!-- GCM requires a Google account (necessary only if if the device is running a version lower than Android 4.0.4). -->
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>

<!-- Optional. Prevents the device from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<permission android:name="[com.YOUR_PACKAGE].permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="[com.YOUR_PACKAGE].permission.C2D_MESSAGE" />

<!-- These permissions are required only for geofencing. -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

<application
  android:allowBackup="true"
  android:icon="@drawable/ic_launcher"
  android:label="@string/app_name"
  android:theme="@style/AppTheme"
  android:name=".[YOUR_APPLICATION_CLASS]" >

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <!-- For GCM push notifications only. Firebase will add this receiver automatically -->
    <receiver
        android:name="com.google.android.gms.gcm.GcmReceiver"
        android:exported="true"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="[com.YOUR_PACKAGE]" />
        </intent-filter>
    </receiver>
    <!-- / GCM receiver -->

    <receiver
        android:name="com.leanplum.LeanplumPushReceiver"
        android:exported="false" >
        <intent-filter>
            <!-- Only add this action for Google Cloud Messaging -->
            <action android:name="com.leanplum.LeanplumPushListenerService" />
            <!-- Only add this action for Firebase Cloud Messaging -->
            <action android:name="com.leanplum.LeanplumPushFirebaseMessagingService" />
        </intent-filter>
    </receiver>


    <service android:name="com.leanplum.LeanplumLocalPushListenerService" />

    <service android:name="com.leanplum.LeanplumPushRegistrationService" />

    <!-- The next two services are only needed for GCM. You do not need them for Firebase -->
    <service
        android:name="com.leanplum.LeanplumPushListenerService"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
    </service>

    <service
        android:name="com.leanplum.LeanplumPushInstanceIDService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.android.gms.iid.InstanceID" />
        </intent-filter>
    </service>

    <!-- Add the next two services for Firebase Cloud Messaging -->
    <service
        android:name="com.leanplum.LeanplumPushFirebaseMessagingService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>
    <service
        android:name="com.leanplum.LeanplumPushFcmListenerService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
        </intent-filter>
    </service>

  <!-- For geofencing only -->
  <service android:name="com.leanplum.ReceiveTransitionsIntentService" />

  <activity
      android:name="[com.YOUR_PACKAGE].MainActivity"
      android:label="@string/app_name" >
      <intent-filter>
          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
  </activity>
</application>

</manifest>

Was this article helpful?
Have more questions? Submit a request