gpt4 book ai didi

android - 在 android 模拟器中运行 react-native

转载 作者:行者123 更新时间:2023-11-29 16:53:08 27 4
gpt4 key购买 nike

我正在尝试运行 init react-native 项目,但出于某种原因我收到了 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)...

但在设备上我收到此错误(在红色屏幕上),

The development server returned response error code: 500

URL: http://10.0.2.2:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false

Body:
{"message":"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\")","type":"TransformError","lineNumber":0,"description":"","errors":[{"description":"","lineNumber":0}]}
processBundleResult
BundleDownloader.java:170
access$100
BundleDownloader.java:39
onResponse
BundleDownloader.java:139
execute
RealCall.java:135
run
NamedRunnable.java:32
runWorker
ThreadPoolExecutor.java:1162
run
ThreadPoolExecutor.java:636
run
Thread.java:764

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

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\")"

没看懂,react-native的init工程怎么会报错?或者我做错了什么?我不确定了,谢谢!

最佳答案

我认为您正在使用新版本的 babel-preset-react-native 库,并且该新版本中有一个不受支持的尾随逗号。

您可以安装以前版本的库:

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

编辑 - 您可以在 playframework 存储库上看到问题:issue#15513

关于android - 在 android 模拟器中运行 react-native,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45773121/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com