我在Android Studio 3.2中新建了项目 Build#AI-181.5540.7.32.5014246,建于2018年9月18日 JRE:1.8.0_152-release-1136-b06 amd64 JVM:JetBrains s.r.o的OpenJDK 64位服务器VM Windows 10 10.0无法生成或同步失败。出现以下异常,
,但是此后每次同步项目时都无法同步,如下所示,
找不到等级DSL方法:“ google()” 可能的原因:
app \ build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.1.1"
defaultConfig {
applicationId "com.example.dip.bigwave"
minSdkVersion 26
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'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
application build.gradle (Project name: BigWave)
// 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:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
错误日志:-
2019-11-03 21:49:56,295 [ thread 27] WARN - nal.AbstractExternalSystemTask - Cause: maven.google.com
com.intellij.openapi.externalSystem.model.ExternalSystemException: Cause: maven.google.com
2019-11-03 21:52:33,089 [ thread 22] INFO - .project.GradleProjectResolver - Gradle project resolve error
org.gradle.tooling.BuildException: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.0-milestone-1-all.zip'.
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method google() for arguments [] on repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler.
at org.gradle.internal.metaobject.AbstractDynamicObject.methodMissingException(AbstractDynamicObject.java:179)
WARN - nal.AbstractExternalSystemTask - Could not find method google() for arguments [] on repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler.
com.intellij.openapi.externalSystem.model.LocationAwareExternalSystemException: Could not find method google() for arguments [] on repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler