【发布时间】:2017-10-11 07:58:49
【问题描述】:
要安装的信息源: - https://facebook.github.io/react-native/docs/getting-started.html
另外,我添加了环境变量。
然后使用这些命令,完美运行:
npm 开始 npm 运行安卓
然后当我运行这个命令时:
react-native run-android
它显示了这个error:
Image showing error stack
D:\Projects\React-Native\AwesomeProject>react-native run-android
Scanning 768 folders for symlinks in D:\Projects\React-Native\AwesomeProject\nod
e_modules (31ms)
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat install
Debug)...
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\Projects\React-Native\AwesomeProject\android\app\build.gradle' li
ne: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : U
nsupported major.minor version 52.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: 3.124 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
events.js:182
throw er; // Unhandled 'error' event
^
Error: spawn cmd.exe ENOENT
at _errnoException (util.js:1019:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:192:19)
at onErrorNT (internal/child_process.js:374:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
构建 gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// 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"
}
}
}
【问题讨论】:
-
你能分享你的gradle文件吗?那真的很有帮助
-
@HarkiratSaluja 添加了
标签: android react-native installation