要安装的信息来源: - https://facebook.github.io/react-native/docs/getting-started.html
另外,我添加了环境变量。
然后使用这些完美运行的命令:
npm开始 npm运行android
然后当我运行此命令时:
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)
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"
}
}
}
答案 0 :(得分:0)
显然你的build.gradle文件中有错误。
不看文件,我想它可能与最小的Android版本或类似的东西有关。
此gradle文件包含构建Android应用程序的所有信息,因此如果它包含错误,则会出现“FAILURE:Build failed with anception。”
答案 1 :(得分:0)
我通过添加适当的环境变量路径解决了这个问题。请参阅附件截图。
C:\ Windows \ System32下* WindowsPowerShell \ V1.0 * ;
C:\ Users \用户gyrix **应用程序数据\漫游\ NPM **;
C:\用户\ gyrix **应用程序数据\本地\纱\ BIN **;
d:\ Android的\ sdk1 **平台工具**;
E:\ Android的SDK **构建工具\ 25.0.2 **;
d:\的Android ** ** sdk1;
d:\ Android的\ sdk1 ** **工具;
C:\ Program Files ** Java \ jdk1.8.0_144 \ bin **;
注意:请以粗体指定文件夹的路径,它可能因系统而异。 enter code here