Gradle sync failed: Could not find property 'compile' on


(santiago pereira) #1

Hi, I bought a source code and Im getting this error:

Gradle sync failed: Could not find property ‘compile’ on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@6a23f3c7.
Consult IDE log for more details (Help | Show Log)

Build.Gradle:

[CODE]
buildscript {
repositories {
mavenCentral()
maven { url “https://oss.sonatype.org/content/repositories/snapshots/” }
}
dependencies {
classpath ‘com.android.tools.build:gradle:1.2.3’
}
}

allprojects {
apply plugin: "eclipse"
apply plugin: “idea”

version = '1.0'
ext {
    appName = "Tic Tac Toe"
    gdxVersion = '1.7.0'
    roboVMVersion = '1.8.0'
    box2DLightsVersion = '1.4'
    ashleyVersion = '1.6.0'
    aiVersion = '1.6.0'
}

repositories {
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}

}

project(":android") {
apply plugin: “android”

configurations { natives }

dependencies {
    compile project(":core")
    compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
    compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
    natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
    natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
    natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
}

}

project(":core") {
apply plugin: “java”

dependencies {
    compile "com.badlogicgames.gdx:gdx:$gdxVersion"
    compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
}

}

tasks.eclipse.doLast {
delete “.project”
}
[/CODE]

Can anyone help?

Thank you


(Francois Ritaly) #2

Your root project defines compile and natives dependencies (see below) however it doesn’t apply any plugin plugin which defines them (they need to be defined somewhere).

dependencies {
    compile project(":core")
    compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
    compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
    natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
    natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
    natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
}

It looks like the root project should apply a plugin (I’m not sure which one) which should define the compile and natives configurations


(James Justinic) #3

@Francois_Ritaly - The indention is a bit off in what was posted, so it’s harder to see, but there aren’t any dependencies defined on the root project. The compile and natives dependencies are on the android project, not the root project. The android project applies the the android plugin and declares the natives configuration.

I cannot reproduce the same error shown above with this script. The only errors I see come from the Android plugin and are due to missing required items in the android project, which makes sense as I started with an empty project. It appears I can resolve these with minimal versions of what should be present in the project.

I don’t think the actual problem is shown in the build.gradle file included (or it’s not the build.gradle file causing the issue). Do you have other *.gradle files in your project that you can share @Santouy?