0

I'm following the instructions for integrating Flurry Analytics using the official tutorial

I run into the problem that has been widely reported:

Error:(4, 0) Gradle DSL method not found: 'compile()' Possible causes:

  • The project 'My_Project' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file
  • The build file may be missing a Gradle plugin. Apply Gradle plugin
  • Here's the gradle file for the FlurryAnalytics-5.5.0 module autogenerated by Studio:

    configurations.create("default")
    artifacts.add("default", file('FlurryAnalytics-5.5.0.jar'))
    dependencies {
        compile files('FlurryAnalytics-5.5.0.jar')
    }
    

    I'm aware that a common solution prescribed in such questions as this one is to avoid putting the 'dependencies' closure in the top level build file. However, I don't have any non-gradle dependencies in that file, as is shown below.

    build.gradle:

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.0.0'
        }
    }
    
    allprojects {
        repositories {
            jcenter()
        }
    }
    
    Community
    • 1
    • 1
    kip2
    • 6,473
    • 4
    • 55
    • 72

    1 Answers1

    1

    The compile option is a part of the Android Gradle Plugin.

    You need to apply that plugin to your module's build.gradle file if the module is an Android module.

    apply plugin: 'com.android.application' // Android Gradle Pllugin
    
    android {
        // Your Android configuration
    }
    

    With Jar:

    dependencies {
        compile files('FlurryAnalytics-5.5.0.jar') // Your Jar
    }
    

    or Maven Dependency:

    dependencies {
        compile 'com.flurry.android:analytics:6.2.0' // Latest Jcenter release
    }
    
    Jared Burrows
    • 54,294
    • 25
    • 151
    • 185
    ugo
    • 2,705
    • 2
    • 30
    • 34
    • This makes sense. I had wanted to make Flurry a module of its own. What a mistake. Well, thank you! It'd be nice to have Flurry available on one of the Maven repos so we don't have to deal with jars at all :) – kip2 Jun 25 '15 at 01:08
    • I'm just about to add flurry to my app, and looked for it on http://gradleplease.appspot.com/ which gave me back compile 'io.segment.analytics.android:flurry:1.3.1'. Are you guys really saying that flurry isn't on gradle/maven yet!!?? – Russ Wheeler Aug 03 '15 at 11:05
    • @RussWheeler It is on Jcenter. – Jared Burrows Mar 07 '16 at 08:12