我正在开发新闻应用程序,但出现以下错误。
Gradle DSL method not found: 'compileSdkVersion()'
Possible causes: The project 'app' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 3.2.0 and sync project The project 'app' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file The build file may be missing a Gradle plugin.
Apply Gradle plugin.
我已遵循堆栈溢出的所有可能解决方案,但它并没有解决我的问题。
在我的 build.gradle
下方:
apply plugin: 'com.android.application'
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
signingConfigs {
config {
keyAlias 'key0'
keyPassword 'Adilnoz1992'
storeFile file('yodgor.jks')
storePassword 'Aziyoda1990'
}
}
}
compileSdkVersion 28
defaultConfig {
applicationId "org.edgar.komilov.news"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
flavorDimensions "default"
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.config
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.picasso:picasso:2.3.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.google.android.gms:play-services-ads:17.0.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
}
apply plugin: 'com.google.gms.google-services'
在我的根 build.gradle
下:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
最佳答案
删除 compileSdkVersion 28
上面多余的花括号 }
并将其添加到 dependencies
block 之上,如下所示
apply plugin: 'com.android.application'
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
signingConfigs {
config {
keyAlias 'key0'
keyPassword 'Adilnoz1992'
storeFile file('yodgor.jks')
storePassword 'Aziyoda1990'
}
}
compileSdkVersion 28
defaultConfig {
applicationId "org.edgar.komilov.news"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
flavorDimensions "default"
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.config
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.picasso:picasso:2.3.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.google.android.gms:play-services-ads:17.0.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
}
apply plugin: 'com.google.gms.google-services'
关于android - 我收到 Gradle DSL 方法未找到错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52756412/