Integration steps
In Android Studio, go to File -> New -> New Module -> Import .JAR/.AAR Package.
- Select the AttributoSDK-release.aar file and create the subproject.
- Now that the AttributoSDK-release subproject has been created in your project, include it in your app's build.gradle:
implementation project (':AttributoSDK-release')
- Include the Play Install Referrer library and import it into your project.
implementation 'com.android.installreferrer:installreferrer:1.1'
If you receive an error after adding this dependency, check that your top-level build.gradle contains a reference to:maven { url "https://maven.google.com" }
- Install the Android Support Library and import it into your project. implementation ‘androidx.appcompat:appcompat:1.1.0'
Code Changes
Google Play Services
Install the Google Play Services SDK and import it into your project in order for the SDK to collect the Google Advertising ID. If you’re using Gradle, you may choose to add only the ads library to your dependencies:
implementation 'com.google.android.gms:play-services-basement:X.X.X'Replace X.X.X with the latest version from https://developers.google.com/android/guides/setup
ProGuard
If using ProGuard, exclude the Attributo and Google Advertising ID classes from obfuscation in your ProGuard configuration file with the following lines:
-keep public class com.google.android.gms.ads.identifier.** { *; }
Android Manifest File
Add the following sections to your AndroidManifest.xml file:
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <application> <receiver android:name="com.attributo.AttributoTracker"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER" /> </intent-filter> </receiver> </application>
Initialize Attributo SDK
Initialize SDK with your appId and secretKey
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Attributo.init(this, "YOUR_APPID", "YOUR_SECRETKEY"); // measure some event Attributo.getInstance().measureEvent("YOUR_EVENT"); } @Override protected void onResume() { super.onResume(); Attributo.getInstance().measureSession(); } }