Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android emulator中运行react native_Android_React Native_React Native Android - Fatal编程技术网

在android emulator中运行react native

在android emulator中运行react native,android,react-native,react-native-android,Android,React Native,React Native Android,我试图运行init react本机项目,由于某种原因,我得到了一个500错误 这是控制台日志 Danny@DESKTOP-GIRS9GM /cygdrive/c/Users/Danny/Desktop/TestProject $ react-native run-android Scanning 557 folders for symlinks in C:\Users\Danny\Desktop\TestProject\node_modules (29ms) JS server already

我试图运行init react本机项目,由于某种原因,我得到了一个500错误

这是控制台日志

Danny@DESKTOP-GIRS9GM /cygdrive/c/Users/Danny/Desktop/TestProject
$ react-native run-android
Scanning 557 folders for symlinks in C:\Users\Danny\Desktop\TestProject\node_modules (29ms)
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComFacebookFbuiTextlayoutbuilderTextlayoutbuilder100Library UP-TO-DATE
:app:prepareComFacebookFrescoDrawee101Library UP-TO-DATE
:app:prepareComFacebookFrescoFbcore101Library UP-TO-DATE
:app:prepareComFacebookFrescoFresco101Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipeline101Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipelineBase101Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipelineOkhttp3101Library UP-TO-DATE
:app:prepareComFacebookReactReactNative0471Library UP-TO-DATE
:app:prepareComFacebookSoloaderSoloader010Library UP-TO-DATE
:app:prepareOrgWebkitAndroidJscR174650Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:bundleDebugJsAndAssets SKIPPED
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:transformClassesWithDexForDebug UP-TO-DATE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:validateSigningDebug
:app:packageDebug UP-TO-DATE
:app:assembleDebug UP-TO-DATE
:app:installDebug
Installing APK 'app-debug.apk' on 'Nexus_5X_API_26(AVD) - 8.0.0' for app:debug
Installed on 1 device.

BUILD SUCCESSFUL

Total time: 15.967 secs
Running C:\Users\Danny\AppData\Local\Android\sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081
Starting the app on emulator-5554 (C:\Users\Danny\AppData\Local\Android\sdk/platform-tools/adb -s emulator-5554 shell am start -n com.testproject/com.testproject.MainActivity)...
但是在设备上我得到了这个错误(在红色屏幕上)

这是打开的窗口中的消息(当我运行react native run android时)


我不明白,为什么react native的init项目会出现错误?还是我做错了什么?我不确定了,谢谢

我认为您使用的是新版本的
babel-reset-react-native
库,新版本上有一个不受支持的尾随逗号

您可以安装库的早期版本:

npm uninstall babel-preset-react-native
npm install babel-preset-react-native@2.1.0

编辑-您可以在playframework存储库中看到问题:

您可以粘贴index.android.js代码吗。如果react-native不是最新版本,请尝试将其更新为最新版本。以下是index.android.js代码(来自npm安装)->并且react-native的版本为“react-native”:“0.47.1”(最新版本)安装以前的版本解决了此问题,我试着像你说的那样去掉逗号,但还是有同样的问题。谢谢没问题,我正在删除关于逗号的答案,可能库尝试转换的其他文件中有逗号
error: bundling failed: "TransformError: C:\\Users\\Danny\\Desktop\\TestProject\\index.android.js: Unexpected token ) (While processing preset: \"C:\\\\Users\\\\Danny\\\\Desktop\\\\TestProject\\\\node_modules\\\\babel-preset-react-native\\\\index.js\")"
npm uninstall babel-preset-react-native
npm install babel-preset-react-native@2.1.0