React Native:意外标记的转换错误(
问题描述:
我按照React Native's Android Setup Page中显示的确切说明执行了代码,并且昨天没有遇到任何问题,现在我试着运行完全相同的代码。 “构建是成功的”,但我看到的只有android/build/intermediates/dex-cache/cache.xml
文件,并没有更多的android/builid
文件夹还具有以下错误as shown in this image我试图弄清楚什么是错在这里是终端输出:。React Native:意外标记的转换错误(
[email protected]:~/Desktop/tutorials/react native tutorial/NewPro$ react-native run-android
Scanning 559 folders for symlinks in /home/ugur/Desktop/tutorials/react native tutorial/NewPro/node_modules (2ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew 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 'SM-N910C - 6.0.1' for app:debug
Installed on 1 device.
BUILD SUCCESSFUL
Total time: 17.032 secs
Running /home/ugur/Android/Sdk/platform-tools/adb -s 4100fef8e47db1b3 reverse tcp:8081 tcp:8081
adb server version (32) doesn't match this client (39); killing...
* daemon started successfully *
Starting the app on 4100fef8e47db1b3 (/home/ugur/Android/Sdk/platform-tools/adb -s 4100fef8e47db1b3 shell am start -n com.newpro/com.newpro.MainActivity)...
Starting: Intent { cmp=com.newpro/.MainActivity }
我的操作系统是Elementary OS,Node v6.11.2,react-native-cli v2.0.1。
如果你指导我找出我的构建出了什么问题,我会很高兴。
答
这是与babel-preset-react-native
模块相关的内容。尝试运行,
yarn remove babel-preset-react-native
yarn add [email protected]
或者,如果您使用NPM,
npm uninstall babel-preset-react-native
npm install [email protected]
答
删除node_modules文件夹,然后运行命令。
npm install
然后运行该项目。
答
试图杀死在端口8081
任何过程,如果你是在Mac上,然后运行以下命令
sudo lsof -n -i4TCP:8081
答
回答了这个话题:https://*.com/a/45778766/4621698
这对我有用。
解决方法:
"dependencies": {
"react": "16.0.0-alpha.12",
"react-native": "0.47.1",
"babel-preset-react-native": "2.1.0"
},
见上文,现在巴别预置反应的天然分2.1.0。 然后,
rm -rf node_module
npm cache clean
npm i
,并重新启动取其Android或iOS。
我爱你
似乎有一些3.0的问题或文档不符合新的变化。 –
是的,它工作! –