编译时老是报如下错误:
Error:Could not find com.android.tools.build:gradle:2.2.0.
Searched in the following locations:
file:/D:/software/android-studio/gradle/m2repository/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.pom
file:/D:/software/android-studio/gradle/m2repository/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.jar
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.jar
解决办法:添加
jcenter()
比如下面的代码
buildscript { repositories { jcenter() mavenCentral() } // Switch the Android Gradle plugin version requirement depending on the // installed version of Gradle. This dependency is documented at // http://tools.android.com/tech-docs/new-build-system/version-compatibility // and https://issues.apache.org/jira/browse/CB-8143 dependencies { classpath 'com.android.tools.build:gradle:2.2.0' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' } } // Allow plugins to declare Maven dependencies via build-extras.gradle. repositories { jcenter() mavenCentral() }