AppsFlyer SDK Integration in Android

Posted By : Prince Bhardwaj | 10-Apr-2017

To integrate Appsflyer in your project, you have to add following in your app level gradle.build -

repositories {
	mavenCentral() 
}
dependencies {
 compile 'com.appsflyer:af-android-sdk:4+@aar'
 ...
 ..
}
 

After you are done with your gradle.build dependency, make sure to include following permissions in AndroidManifest.xml -

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Now you have to set an install referral broadcast receiver in your AndroidManifest.xml-

1. If you have to use multiple install referral broadcast receiver in your project, add the following receiver as the first receiver -

<!—The AppsFlyer Install Receiver is first and will broadcast to all receivers placed below it -->
<receiver android:name="com.appsflyer.MultipleInstallBroadcastReceiver" android:exported="true">
  <intent-filter>
     <action android:name="com.android.vending.INSTALL_REFERRER" />
  </intent-filter>
</receiver>
<!—All other receivers should follow right after -->     

2. If you are using single broadcast receiver, add these lines in your application tag in AndroidManifest.xml-

 

<receiver android:name="com.appsflyer.SingleInstallBroadcastReceiver" android:exported="true">
           <intent-filter>
               <action android:name="com.android.vending.INSTALL_REFERRER" />
           </intent-filter>
</receiver>

To start tracking add this line to you application class onCreate function -


AppsFlyerLib.getInstance().startTracking(this.getApplication(),"REPLACE WITH YOUR DEV KEY");

THANKS

About Author

Author Image
Prince Bhardwaj

Prince Bhardwaj is having Talent as Application Developer, he is an enthusiastic team player in Oodles Technologies.

Request for Proposal

Name is required

Comment is required

Sending message..