0

Recently, I wanted to implement flurry analytics to my android app However, after I followed the instructions and run the program, I'd faced the error shown below.

Thank you so much for your help and appreciate it!

Program type already present: com.flurry.android.Consent

Message{kind=ERROR, text=Program type already present: com.flurry.android.Consent, sources=[Unknown source file], tool name=Optional.of(D8)}

The app-level gradle code are here:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.falcontech.falcontech"
        minSdkVersion 14
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies
        {
            implementation fileTree(include: ['*.jar'], dir: 'libs')
            implementation 'com.android.support:appcompat-v7:26.1.0'
            implementation 'com.android.support.constraint:constraint-layout:1.0.2'
            //implementation 'com.google.android.gms:play-services-plus:15.0.0'
            //$
            testImplementation 'junit:junit:4.12'
            androidTestImplementation 'com.android.support.test:runner:1.0.1'
            androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
            implementation files('/Users/Frank/Desktop/Desktop/flurry_Android_sdk 2/Flurry-Analytics/flurryAnalytics_10.0.0.jar')
            implementation 'com.google.android.gms:play-services-analytics:15.0.0'
        }

The application-level gradle are here:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:3.1.1'
        // Add this line
        classpath 'com.google.gms:google-services:3.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Hanqing Zhao
  • 25
  • 2
  • 7
  • Is there a particular reason for you to use flurry from an jar ? (instead of `implementation 'com.flurry.android:analytics:10.0.0@aar'`) – xiaomi Apr 21 '18 at 14:28
  • No, I just followed instruction online and it told me to include jar into my code. Otherwise, I won't add it. Do you mean I can remove it from my code or other way to solve that? thx – Hanqing Zhao Apr 24 '18 at 14:45
  • The [doc](https://developer.yahoo.com/flurry/docs/integrateflurry/android) says that it is preferable to use gradle via jcenter than adding the jar file, can you give a try via gradle ? – xiaomi Apr 24 '18 at 15:09
  • I've tried before but there were some error with red color saying that "cannot resolve symbol "FlurryAgent" " " VERBOSE" Can you help me solve that thank you so much! – Hanqing Zhao Apr 24 '18 at 16:55
  • Instruction asked me to add some sample code into my code – Hanqing Zhao Apr 24 '18 at 16:57

2 Answers2

1

You can integrate via aar by adding the following in your main app's Gradle config file:

repositories {
    jcenter()
  }

dependencies {
    // Required for Flurry Analytics integration
    compile 'com.flurry.android:analytics:10.0.0@aar'
}

Remove the permissions you added to your Manifest file, and the jar files, then sync your gradle file. In your application class, make sure to include the following:

import com.flurry.android.FlurryAgent;
import static android.util.Log.VERBOSE;
  • Thank you so much, after I import those two lines of code, the error was gone. However, there is a new fail error in gradle file : ---> Could not find method compile() for arguments [com.flurry.android:analytics:10.0.0@aar] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. – Hanqing Zhao Apr 26 '18 at 14:50
  • Could you help me out for this errer, appreciate it! – Hanqing Zhao Apr 26 '18 at 14:51
  • Hello Staff, After doing some endeavor, there is also an error here. --------- Program type already present: com.flurry.android.FlurryAgent$1 Message{kind=ERROR, text=Program type already present: com.flurry.android.FlurryAgent$1, sources=[Unknown source file], tool name=Optional.of(D8)} Thank you so much! – Hanqing Zhao Apr 30 '18 at 16:24
0

You may have the dependencies listed in the wrong gradle file. They should be in the same location as your jar is included in the original code posted.

In addition, you'll want to update minSdkVersion to 16, which is the minimum supported in 10.0.0.

  • Could you explain in detail about this sentence "You may have the dependencies listed in the wrong gradle file. They should be in the same location as your jar is included in the original code posted."?Thank you. – Hanqing Zhao Apr 30 '18 at 14:46
  • They should be in the section you have titled above, "The app-level gradle code are here" – Flurry Analytics Support May 23 '18 at 23:11