使用init命令创建react本机项目

时间:2017-11-04 09:19:49

标签: android react-native sdk

我尝试使用react-native init NewProject命令创建新项目。 该项目已成功创建,但当我尝试在genymotion android模拟器上运行项目:react-native run-android时,我得到以下输出:

>C:\IdeaProjects\proj>react-native run-android

Scanning folders for symlinks in C:\IdeaProjects\proj\node_modules (56ms)
JS server already running.

Building and installing the app on the device (cd android && gradlew.bat installDebug)...

Observed package id 'platform-tools' in inconsistent location 'C:\Android\Sdk\platform-tools' (Expected 'C:\Android\Sdk\platform-tools\platform-tools')     

Observed package id 'platform-tools' in inconsistent location 'C:\Android\Sdk\platform-tools' (Expected 'C:\Android\Sdk\platform-tools\platform-tools')

Observed package id 'platform-tools' in inconsistent location 'C:\Android\Sdk\platform-tools' (Expected 'C:\Android\Sdk\platform-tools\platform-tools')

Checking the license for package Android SDK Build-Tools 23.0.2 in C:\Android\Sdk\platform-tools\licenses

License for package Android SDK Build-Tools 23.0.2 accepted.

Preparing "Install Android SDK Build-Tools 23.0.2".

>Warning: Trying to install into C:\Android\Sdk\platform-tools\build-tools\23.0.2\ but package "Android SDK Platform-Tools" already exists at C:\Android\Sdk\platform-tools\. It must be deleted o
r moved away before installing into a child directory.

Checking the license for package Android SDK Platform 23 in C:\Android\Sdk\platform-tools\licenses

License for package Android SDK Platform 23 accepted.

Preparing "Install Android SDK Platform 23".

>Warning: Trying to install into C:\Android\Sdk\platform-tools\platforms\android-23\ but package "Android SDK Platform-Tools" already exists at C:\Android\Sdk\platform-tools\. It must be deleted
 or moved away before installing into a child directory.


FAILURE: Build failed with an exception.

A problem occurred configuring project ':app'.
> Failed to install the following SDK components:
  [Android SDK Platform 23, Android SDK Build-Tools 23.0.2]
  Please install the missing components using the SDK manager in Android Studio.

我已经成功安装:

  • Android SDK Platform 30
  • Android SDK Build-Tools 23.0.2

有人可以看一下吗?我读了一些主题但没有成功..

2 个答案:

答案 0 :(得分:0)

有非常好的文档available here。请参阅此处的“使用本机代码构建项目”部分。

您可能需要设置nodewatchman以及其他一些依赖项,例如python2react-native-cli。还有一些其他配置,具体取决于您使用的是Mac还是Windows。

您可能也想看看Create-React-Native-App。这是最容易上手的推荐方式。

答案 1 :(得分:0)

您无法使用旧版构建工具构建新SDK。构建工具的主要版本应该不小于SDK。工作设置示例:

  • Android SDK Platform 25
  • Android SDK Build-Tools 25.0.3