Java 在 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@397740e0 上找不到属性“compile”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33991832/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not find property 'compile' on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@397740e0
提问by Nicholas Muir
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.
我正在使用parse.com
入门程序进行为期两天的讲座,没有任何问题。我离开了几分钟,没有任何我可以看到的变化,现在它不会同步。我已经搜索过,但没有发现任何我看不到的错误。在此先感谢您的帮助。
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:
这是我的gradle文件:
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
}
*/
采纳答案by Akhil Cherian Verghese
You've used compile as a property, but it isn't one. You need to pass a string argument to it.
您已经使用 compile 作为一个属性,但它不是一个属性。您需要向它传递一个字符串参数。
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.
编辑:正如人们在评论中提到的,您不应该有两个相同的依赖项。但是,这不会导致您描述的问题。我相信当您使用 gradle 构建时,它可能会导致“意外的顶级异常”。
回答by Mathulan
I had the same error, and as @Akhil suggested you have to make sure the compile syntax is as above.
我有同样的错误,正如@Akhil 建议你必须确保编译语法如上。
For me after an upgrade the gradle compile lines breaks were removed,
对我来说,升级后 gradle 编译换行符被删除了,
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'
回答by Mladen Rakonjac
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'