Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add flurry into android studio project? [duplicate]

Tags:

android

flurry

How can I add flurry into my android studio project, I haven't done this before, so I am not entirely sure where to add the files? I have FlurryAnalytics.jar

and how to use in my app?

thanx

like image 901
Bohrend Avatar asked Nov 18 '13 12:11

Bohrend


1 Answers

Here is how I added Flurry:

  • Add FlurryAnalytics_3.3.2.jar (or latest) to libs folder (create this directory if necessary)

    • Add compile fileTree(dir: 'libs', include: '*.jar') to the dependencies in your project's build.gradle

      dependencies { compile fileTree(dir: 'libs', include: '*.jar') }

  • or Gradle + Jcenter compile 'com.flurry.android:analytics:6.2.0'

  • Add appropriate permissions to AndroidManifest.xml:

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    
  • Make sure a versionName attribute is specified in AndroidManifest.xml to have data reported under that version name, such as:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0">
    
  • Optionally, add you Flurry API key to a constants file, such as AppConstants.java:

    public class AppConstants {
        public static final String FLURRY_API_KEY = "YOUR_API_KEY"; // where YOUR_API_KEY  is your actual API key from FLURRY similar to 1ABCDE23EFGH4IJKLMN5O
    
  • Add the Flurry onStartSession and onEndSession to each activity in your app:

    @Override
    protected void onStart()
    {
        super.onStart();
        FlurryAgent.onStartSession(this, AppConstants.FLURRY_API_KEY);
    }
    
    @Override
    protected void onStop()
    {
        super.onStop();
        FlurryAgent.onEndSession(this);
    }
    

I still had some issues at this point and selected a hint recommended by Android Studio while viewing my build.gradle file. It changed gradle-1.8-bin.zip to gradle-1.8-bin.zip to gradle-1.8-all.zip in gradle/wrapper/gradle-wrapper.properties:

distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-all.zip

After this, my project built successfully and started to log Flurry events. FYI, it takes a few hours to see the logs in Flurry.

This is a good reference for Android Studio and gradle

And of course, Flurry provided the details for much of this as well.

like image 116
David M Avatar answered Nov 10 '22 15:11

David M