【原创】解决React Native报错:Could not find method google() for arguments [] on repository container
问题背景:
运行 react-native run-android 后报错:
问题原因:
1. 这是由于三者的版本过低以及版本不一致造成的【Gradle 插件版本、Gradle发行版本以及 Android SDK Build Tools 版本】。
2. 关于Gradle所涉及的版本请移步金牛座另一篇博文了解更多: http://www.blogdaren.com/post-2418.html
解决方案:
1. 修改 /path/to/project/android/build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() 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" } google() } } subprojects { project.configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'com.android.support' && !details.requested.name.contains('multidex') ) { details.useVersion "27.1.0" } } } }2. 修改 /path/to/project/android/gradle/wrapper/gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip3. 修改 /path/to/project/android/app/build.gradle:
android{ compileSdkVersion 27 buildToolsVersion "27.0.0" ...... ...... }
版权声明:除非注明,本文由( blogdaren )原创,转载请保留文章出处。
本文链接:【原创】解决React Native报错:Could not find method google() for arguments [] on repository container
发表评论: