Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native: Transform Error for Unexpected Token (

I have followed the exact instructions shown in React Native's Android Setup Page and run the code without facing any problems yesterday. Today, I am trying to run the exact same code. It says as I have provided below "build is succesful", yet I see there is only android/build/intermediates/dex-cache/cache.xml file and nothing more in android/builid folder . Also have the following error as shown in this image. I am trying to figure out what is wrong. Here is the terminal output:

ugur@ugur-Lenovo-ideapad-510-15IKB:~/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 }

My OS is Elementary OS, Node v6.11.2, react-native-cli v2.0.1.

I would be glad if you guide me to find out what is going wrong with my build.

like image 517
Uğur Kaya Avatar asked Aug 16 '17 22:08

Uğur Kaya


2 Answers

This is something related to babel-preset-react-native modules. Try to run,

yarn remove babel-preset-react-native
yarn add [email protected]

Or if you use NPM,

npm uninstall babel-preset-react-native
npm install [email protected]
like image 98
geckob Avatar answered Nov 07 '22 23:11

geckob


Answered to this in the topic: https://stackoverflow.com/a/45778766/4621698

This worked for me.

Workaround:

"dependencies": {
"react": "16.0.0-alpha.12",
"react-native": "0.47.1",
"babel-preset-react-native": "2.1.0"
},

See above, now babel-preset-react-native points to 2.1.0. Then,

rm -rf node_module
npm cache clean
npm i

And restart whichever android or ios.

like image 30
Yuki Tanaka Avatar answered Nov 07 '22 23:11

Yuki Tanaka