1.報錯信息以下:android
Gradle DSL method not found: 'google()'
Possible causes: The project 'JustTest' 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.1.2 and sync project The project 'Test' 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 api
錯誤緣由分析:沒找到google(),The google() repo is a shortcut to looks in Google's Maven repository for dependencies. It was introduced with gradle v.4.0。(使用條件)It requires (currently)Gradle v.四、Android Studio 3.x.、Gradle plugin for Android 3.xapp
解決問題辦法:將google()替換成maven {url 'https://maven.google.com'}maven
2.報錯信息以下:gradle
No such property: FOR_RUNTIME for class: org.gradle.api.attributes.Usageui
錯誤分析:由於gradle的版本是升級了,簡單作法就是Gradle降級。google
這裏分享一下個人作法:url
1).將gradle-wrapper.properties 中的 url改成:spa
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
2).將項目中的build.gradle改成blog
classpath 'com.android.tools.build:gradle:3.0.0'