Could not find property 'compile' on org.g

2019-01-17 06:52发布

问题:

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
}
*/

回答1:

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:

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'


回答3:

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'