引用:https://www.cnblogs.com/caoxinyu/p/10568462.htmljavascript
build.gradle 可能有多個,通常在app 節點,默認裏面不包含buildscript,allprojects 這兩項。
把這段代碼加入 build.gradle (Moudle:app) 尾部:
buildscript {
repositories {
maven{ url = "http://maven.aliyun.com/nexus/content/groups/public/" } google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.1.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { maven{ url = "http://maven.aliyun.com/nexus/content/groups/public/" } google() jcenter() } }