【原创】解决React Native报错:Could not find com.android.tools.build:gradle:3.0.1
问题背景
升级 gradle plugin V2.2.3 --> gradle plugin V3.0.1后,运行报错:
* What went wrong: A problem occurred configuring root project 'demoProject'. > Could not resolve all files for configuration ':classpath'. > Could not find com.android.tools.build:gradle:3.0.1. Searched in the following locations: https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar Required by: project :
问题原因
新版本 gradle plugin 是需要配置 maven 仓库的
解决方案
在 /path/to/project/android/build.gradle 文件的 buildscript 和 allprojects --> repositories 节点分别新增配置 maven 仓库:
buildscript { repositories { jcenter() maven { url 'https://maven.google.com/' name 'Google' } } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { mavenLocal() jcenter() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } maven { url 'https://maven.google.com/' name 'Google' } } }
版权声明:除非注明,本文由( blogdaren )原创,转载请保留文章出处。
本文链接:【原创】解决React Native报错:Could not find com.android.tools.build:gradle:3.0.1
发表评论: