28

I was working through a lecture using the parse.com starter program for two days with no issue. I went away for a few minutes and without anything that I can see being changed and now it won't sync. I have searched but found nothing that I can see wrong. Thanks in advance for your help.

This is the error:

Error:(36, 0) Could not find property 'compile' on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@397740e0.

Open File

This is my gradle file:

apply plugin: 'com.android.application'
apply plugin: 'com.parse'

buildscript {
    repositories {
        mavenCentral()
        maven { 
            url 'https://maven.parse.com/repo' 
        }
    }
    dependencies {
        classpath 'com.parse.tools:gradle:1.+'
    }
}

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.parse.starter"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {


    compile
    'com.android.support:appcompat-v7:22.2.1' compile
    'com.parse.bolts:bolts-tasks:1.3.0' compile
    'com.parse:parse-android:1.11.0' compile
    'com.android.support:design:22.2.1'
    compile 'com.android.support:design:22.2.1'
}

/* Uncomment if you enable ProGuard and you want to automatically upload symbols on build.
parse {
  applicationId "YOUR_APPLICATION_ID"
  masterKey "YOUR_MASTER_KEY"

  // Make symbol upload automatic. Otherwise, use e.g. ../gradlew parseUploadSymbolsDebug;
  uploadSymbols true
}
*/
Jolta
  • 2,620
  • 1
  • 29
  • 42
Nicholas Muir
  • 2,897
  • 8
  • 39
  • 89
  • 1
    compile 'com.android.support:design:22.2.1' ! Y ur using same dependency twice !!!! – Anvesh523 Nov 30 '15 at 05:24
  • 1
    compile 'com.parse.bolts:bolts-tasks:1.3.0' compile 'com.parse:parse-android:1.11.0' If ur using these 2 dependencies U may get other error in future definitely ... so, check this link http://stackoverflow.com/questions/33864267/errorexecution-failed-for-task-appdexdebug-error-in-my-project-while-i-adde – Anvesh523 Nov 30 '15 at 05:28
  • Hi Anvesh I have struggled with this issue before. This is how it comes in the Android starter project from Parse.com. I will research that further. – Nicholas Muir Dec 01 '15 at 04:10
  • 1
    It occurred suddenly when I was adding a Preference Fragment from menu. – ahmadalibaloch Apr 28 '16 at 13:23
  • 3
    For me When creating new activity this issue happened. – iSrinivasan27 Mar 18 '17 at 06:58
  • For me too this happens automatically after creating fragment/activity..dont know why? but everytime this happens i have change it manually – sumitkanoje Oct 22 '17 at 08:33

3 Answers3

60

You've used compile as a property, but it isn't one. You need to pass a string argument to it.

compile 'com.android.support:appcompat-v7:22.2.1' 
compile 'com.parse.bolts:bolts-tasks:1.3.0' 
compile 'com.parse:parse-android:1.11.0'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:design:22.2.1'

EDIT: As people have mentioned in the comments, you shouldn't have two identical dependencies. However this doesn't cause the problem you described. I believe it might cause an "Unexpected Top Level Exception" when you build with gradle.

  • 2
    Thanks too, this strange layout of the "compile" section occurred to me spontaneously : in a project where line breaks were properly placed, at some point somehow they got all messed up line in the OP's code. Weird. It occurred just after a Java JDK update, if that's any clue. – user14764 Jan 21 '16 at 19:25
  • 1
    Awesome, thanks! I didn't notice that the build.gradle was modified by the `Android Studio` strangely. – MewX May 08 '16 at 12:17
  • 1
    Same issue - the problem was caused immediately after updating my Java JDK to 8r92 in the Project Structure dialog. – Knossos May 23 '16 at 07:33
  • IMPORTANT: don't put a comma after each line :) – ACV Sep 23 '16 at 20:12
  • In my case, it's due to formatting issue.Whenever I tried to create new activity whole build.gradle file becomes messy.I don't know the reason.But studio throws same error every time. – Gevaria Purva Apr 11 '17 at 05:53
  • 1
    Google is aware of the bug, but seems to think it has been fixed (in an unspecified pre-release version around July 2016); see [https://issuetracker.google.com/issues/37079036]. I just hit this bug in Android Studio 2.3.1 -- AS mangled my carefully documented (woefully, documented in-line only) dependencies for no reason when I created a FullscreenActivity through the new file wizard, and then presented me with a nonsensical error message. Anyone else who has encountered this issue in a recent AS build, please ping the linked issue tracker so they know the bug is still live – CCJ May 02 '17 at 18:42
  • @CCJ I have encountered with the same error, i have AS 2.3.2. When i create a new activity it is changing my whole `build.gradle`. I have checked with the link you have given but link seems broken. – Ravi Jun 14 '17 at 12:24
  • Just rearrange by pressing `enter`at the end of each row: `compile 'a string here'↲` – Junior Mayhé Jul 06 '17 at 18:00
11
compile
'com.android.support:appcompat-v7:22.2.1' compile
'com.parse.bolts:bolts-tasks:1.3.0' compile
'com.parse:parse-android:1.11.0' compile
'com.android.support:design:22.2.1'
compile 'com.android.support:design:22.2.1'

Just format like this :

compile'com.android.support:appcompat-v7:22.2.1' 
compile 'com.parse.bolts:bolts-tasks:1.3.0' 
compile 'com.parse:parse-android:1.11.0' 
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:design:22.2.1'
Mladen Rakonjac
  • 9,562
  • 7
  • 42
  • 55
4

I had the same error, and as @Akhil suggested you have to make sure the compile syntax is as above.

For me after an upgrade the gradle compile lines breaks were removed,

compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.parse.bolts:bolts-tasks:1.3.0'
compile 'com.parse:parse-android:1.11.0'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:design:22.2.1'
Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
Mathulan
  • 530
  • 5
  • 7
  • No idea why you are answering an already answered question from a year ago. But it is a problem some times when building that causes your gradle file to get be messed up (It still happens on the current version of Android studio / Gradle). – Nicholas Muir Nov 10 '16 at 12:08