配置项目react-native-photo-view

时间:2018-01-12 06:30:17

标签: android react-native-android shoutem

我刚开始使用ReactNative并使用this tutorial创建了一个项目。该项目已经构建,我的手机上安装了一个Android应用程序。

然后我将@shoutem/ui库用于UI组件。根据{{​​3}},我试过了

npm install @shoutem/ui --save
react-native link

然后使用

运行项目
react-native run-android

但后来我收到了这个错误

PS D:\SK\Study\ReactNative\DemoRN> react-native run-android
Scanning folders for symlinks in D:\SK\Study\ReactNative\DemoRN\node_modules (38ms)
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
File C:\Users\sukumar\.android\repositories.cfg could not be loaded.
Failed to download any source lists!
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > A problem occurred configuring project ':react-native-photo-view'.
      > Failed to find Build Tools revision 25.0.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: 11.028 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

然后我取消了@shoutem/ui

的链接
react-native unlink @shoutem/ui

并尝试运行该项目,但仍然,我面临同样的问题?

如果问题太基础,请忽略,但我无法理解问题是什么?

更新

我没有使用Android Studio,所以我下载了build-tools 25.0.0并放在了sdk / build-tools文件夹中。但现在我正面临

> A problem occurred configuring project ':react-native-photo-view'. > Failed to find Platform SDK with path: platforms;android-23

2 个答案:

答案 0 :(得分:2)

这似乎是安装Android Studio时可用SDK工具的一个问题:

      > Failed to find Build Tools revision 25.0.0

安装这些应解决问题。要安装它,请启动Android studio,转到SDK Manager并选择SDK Tools选项卡,检查右下角的Show Package Details选项,然后检查25.0.0 SDK Tools并单击Apply下载并安装他们。

这是我用于本地环境的SDK工具的屏幕截图,供参考:

enter image description here

此外,我想详细说明react-native (un)link命令。这用于将本机依赖项链接到React Native项目。取消链接与卸载它不同,在取消链接包之后,您仍应该能够使用Shoutem UI Toolkit的所有非本机组件。

答案 1 :(得分:1)

我没有使用Android Studio,所以我下载了 build-tools 25.0.0 并放在SDK / build-tools文件夹中。这解决了构建工具问题,但随后出现了新问题

A problem occurred configuring project ':react-native-photo-view'. > Failed to find Platform SDK with path: platforms;android-23 

我使用的网络配置了一些防火墙规则,这些规则不允许下载所需的依赖项。当您运行react-native run-android时,它会自动下载所有依赖项以创建构建。

所以在我的情况下,我改变了我的网络设置,这很有效。