react-native - 无法运行示例应用程序

时间:2017-03-06 18:21:23

标签: react-native

按照教程here,我无法在模拟器中运行该应用程序。当我从DOS提示符执行react-native run-android命令时,这是我得到的错误:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'AwesomeProject'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:2.2.3.
     Required by:
         :AwesomeProject:unspecified
      > Could not resolve com.android.tools.build:gradle:2.2.3.
         > Could not get resource 'https://repo1.maven.org/maven2/com/android/to
ols/build/gradle/2.2.3/gradle-2.2.3.pom'.
            > Could not GET 'https://repo1.maven.org/maven2/com/android/tools/bu
ild/gradle/2.2.3/gradle-2.2.3.pom'.
               > repo1.maven.org
      > Could not resolve com.android.tools.build:gradle:2.2.3.
         > Could not get resource 'https://jcenter.bintray.com/com/android/tools
/build/gradle/2.2.3/gradle-2.2.3.pom'.
            > Could not GET 'https://jcenter.bintray.com/com/android/tools/build
/gradle/2.2.3/gradle-2.2.3.pom'.
               > jcenter.bintray.com

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

我尝试的事情:

  1. 编辑build.gradle文件并从classpath更改classpath' com.android.tools.build:gradle:2.2.3' to com.android.tools.build:gradle:3.3.0' (我使用Android Studio安装的版本)。
  2. 已验证jcenter()在buildcript和allprojects下的build.gradle中列为存储库

2 个答案:

答案 0 :(得分:1)

尝试将其设置为2.3.0

奇怪的是,我看不到那个路径中的任何2.2.3,但我可以看到2.3.0 http://repo1.maven.org/maven2/com/android/tools/build/gradle/

答案 1 :(得分:0)

我使用react-native cli重新创建了项目,问题似乎正在纠正。我应该注意到,当我最初创建项目时,我相信我没有安装android studio,所以也许这与它有关,不确定。