当我创建一个新的空白活动时出现此错误,之前在应用程序中一切正常,它正在运行且没有gradle问题:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '25.0.0'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "ie.example.artur.adminapp"
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':mysql-connector-java-3.0.17-ga-bin')
//Retrofit
compile
'com.android.support:appcompat-v7:24.0.0'compile
'com.android.support:design:24.0.0'compile
'com.squareup.retrofit2:retrofit:2.3.0'compile
'com.squareup.retrofit2:adapter-rxjava2:2.3.0'compile
'com.squareup.okhttp3:logging-interceptor:3.4.1'compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha1'
testCompile 'junit:junit:4.12'
}
这是我得到的错误:
Error:(31, 0) Could not get unknown property 'compile' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
<a href="openFile:C:\Users\family\Desktop\AdminApp-1-v2\app\build.gradle">Open File</a>
答案 0 :(得分:0)
问题在于你的依赖语法。
要修复它,请将依赖项代码修改为:
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':mysql-connector-java-3.0.17-ga-bin')
//Retrofit
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha1'
testCompile 'junit:junit:4.12'