确保您正在运行Android模拟器或已连接设备

时间:2016-06-18 19:15:18

标签: android react-native

我尝试通过我的React Project运行react-native run-android。之后,我收到如下错误。

  Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not find com.android.support:appcompat-v7:23.0.1.
     Searched in the following locations:
         file:/C:/Users/DELL/.m2/repository/com/android/support/appcompat-v7/23.0.1/appcompat-v7-23.0.1.pom
         file:/C:/Users/DELL/.m2/repository/com/android/support/appcompat-v7/23.0.1/appcompat-v7-23.0.1.jar
         https://jcenter.bintray.com/com/android/support/appcompat-v7/23.0.1/appcompat-v7-23.0.1.pom
         https://jcenter.bintray.com/com/android/support/appcompat-v7/23.0.1/appcompat-v7-23.0.1.jar
         file:/F:/Android/react/AwesomeProject/node_modules/react-native/android/com/android/support/appcompat-v7/23.0.1/appcompat-v7-23.0.1.pom
         file:/F:/Android/react/AwesomeProject/node_modules/react-native/android/com/android/support/appcompat-v7/23.0.1/appcompat-v7-23.0.1.jar
     Required by:
         AwesomeProject:app:unspecified
         AwesomeProject:app:unspecified > com.facebook.react:react-native:0.27.2
   > Could not find com.android.support:recyclerview-v7:23.0.1.
     Searched in the following locations:
         file:/C:/Users/DELL/.m2/repository/com/android/support/recyclerview-v7/23.0.1/recyclerview-v7-23.0.1.pom
         file:/C:/Users/DELL/.m2/repository/com/android/support/recyclerview-v7/23.0.1/recyclerview-v7-23.0.1.jar
         https://jcenter.bintray.com/com/android/support/recyclerview-v7/23.0.1/recyclerview-v7-23.0.1.pom
         https://jcenter.bintray.com/com/android/support/recyclerview-v7/23.0.1/recyclerview-v7-23.0.1.jar
         file:/F:/Android/react/AwesomeProject/node_modules/react-native/android/com/android/support/recyclerview-v7/23.0.1/recyclerview-v7-23.0.1.pom
         file:/F:/Android/react/AwesomeProject/node_modules/react-native/android/com/android/support/recyclerview-v7/23.0.1/recyclerview-v7-23.0.1.jar
     Required by:
         AwesomeProject:app:unspecified > com.facebook.react:react-native:0.27.2
   > Could not find com.android.support:support-v4:23.1.1.
     Searched in the following locations:
         file:/C:/Users/DELL/.m2/repository/com/android/support/support-v4/23.1.1/support-v4-23.1.1.pom
         file:/C:/Users/DELL/.m2/repository/com/android/support/support-v4/23.1.1/support-v4-23.1.1.jar
         https://jcenter.bintray.com/com/android/support/support-v4/23.1.1/support-v4-23.1.1.pom
         https://jcenter.bintray.com/com/android/support/support-v4/23.1.1/support-v4-23.1.1.jar
         file:/F:/Android/react/AwesomeProject/node_modules/react-native/android/com/android/support/support-v4/23.1.1/support-v4-23.1.1.pom
         file:/F:/Android/react/AwesomeProject/node_modules/react-native/android/com/android/support/support-v4/23.1.1/support-v4-23.1.1.jar
     Required by:
         AwesomeProject:app:unspecified > com.facebook.react:react-native:0.27.2 > com.facebook.fresco:fresco:0.10.0 > com.facebook.fresco:drawee:0.10.0
         AwesomeProject:app:unspecified > com.facebook.react:react-native:0.27.2 > com.facebook.fresco:fresco:0.10.0 > com.facebook.fresco:imagepipeline:0.10.0
         AwesomeProject:app:unspecified > com.facebook.react:react-native:0.27.2 > com.facebook.fresco:fresco:0.10.0 > com.facebook.fresco:imagepipeline:0.10.0 > com.facebook.fresco:imagepipeline-base:0.10.0

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

BUILD FAILED

Total time: 17.502 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

我安装了Android SDK并成功设置了Android Home和Path Environmental Variable。但我仍然得到同样的错误。

我还在我的电脑上安装了Gennymotion来创建虚拟安卓设备。

7 个答案:

答案 0 :(得分:12)

您可能会检查Android / Gradlew上的权限 它们应该为 755 而不是 644

在应用程序根文件夹中运行'filename': 'zigview\logging_files\debug.log',

然后运行chmod 755 android/gradlew

它应该再次工作。

答案 1 :(得分:2)

修复了.bash_profile

中的以下错误
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
export PATH=$PATH:$JAVA_HOME/bin
export ANDROID_HOME=/Users/saif-ams/MyFiles/applications/androidsdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

答案 2 :(得分:1)

在此React Native AwesomeProject tutorial中,作者指出项目的Android Studio构建版本可能必须在项目的build.gradle文件中更新。

如果您使用的是最新版本的Android Studio,如果您的教程有点老,那么您可能也必须这样做。

找到项目的build.gradle文件,该文件应位于\AwesomeProject\android\app\文件夹中。

build.gradle文件中找到buildToolsVersion "23.0.1"并更改为buildToolsVersion "23.0.3"

请注意,您的文件中可能还有另一个"23.0.1"字符串,但该字符串适用于Android支持版本,并且应保持不变。

答案 3 :(得分:1)

我也遇到了这个问题。这是项目文件夹中的权限问题。我解决了这个问题:

sudo chown -R nomeDoUsuario \AwesomeProject

答案 4 :(得分:1)

  1. 打开Android Studio
  2. 打开任何项目或创建空项目
  3. 查找操作(CMD + SHIFT + A)类型:AVD Manager
  4. 按Enter键打开AVD Manager
  5. 点击小铅笔图标(编辑此AVD)
  6. 点击更改(我们需要Android 6(23)) enter image description here

  7. 然后选择Android 6(23)并单击“确定” enter image description here

  8. 现在点击编辑(铅笔)旁边的播放按钮,并保持模拟器正常运行

  9. 现在打开终端, cd TO_YOUR_PROJECT 然后键入:react-native run-android

  10. 参考:https://facebook.github.io/react-native/docs/getting-started.html

答案 5 :(得分:0)

我刚刚撤消了权限并重新接受了它们。听起来很傻,我知道,但我也先尝试了其他选择,直到我看到Cordova也不认识我的设备。我刚刚拔掉手机,从学校到我家。我希望对于一些人来说,这很容易解决。

答案 6 :(得分:0)

就我而言,我创建了

  

local.properties

在{strong> android 目录中的formData文件