我尝试了所有三种解决方案,但没有一个解决了问题。 错误:未找到 Gradle DSL 方法:“Android()” 可能的原因: 项目“hope”可能使用不包含该方法的 Android Gradle 插件版本(例如“testCompile”是在 1.1.0 中添加的)。 将插件升级到3.5.3版本并同步项目
项目“hope”可能使用不包含该方法的 Gradle 版本。 打开 Gradle 包装文件
构建文件可能缺少 Gradle 插件。 应用 Gradle 插件
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.27.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.dot.name"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
}) Android Gradle Plugin
implementation group: 'org.jsoup', name: 'jsoup', version: '1.12.1'
implementation 'com.android.support:appcompat-v7:28.0.3'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.3'
implementation 'com.jakewharton:butterknife:10.2.1'
implementation 'com.android.support:support-v4:28.0.3'
androidTestImplementation 'junit:junit:4.13'
androidTestImplementation 'org.awaitility:awaitility:4.0.2'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
implementation 'com.android.support:cardview-v7:28.0.3'
implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
transitive = true;
}
}
allprojects {
repositories {
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
我认为这个解决方案可能对您有帮助。我已经将Android添加到
build.gradle
并且出现了这样的问题,然后我将其删除并添加到app/build.gradle
文件中。有效!
事实上,我不知道这两个文件到底有什么区别,但确实有!