race604 / ZhiHuDaily-React-Native

A Zhihu Daily(http://daily.zhihu.com/) App client implemented using React Native (Android and iOS).
MIT License
3.64k stars 807 forks source link

BUILD FAILED #75

Open zhuanglong opened 7 years ago

zhuanglong commented 7 years ago

baidushurufa_2017-2-8_17-34-22

gongzai commented 7 years ago

同问 编译时也遇到了这个问题

zelongg commented 7 years ago

Also encountered the same issue. commit: efc5c76ed2a3581899d3a37a9d0f290021ab532b

:app:bundleDebugJsAndAssets
bundle: Created ReactPackager
uncaught error Error: SyntaxError: /Users/gongzelong/Android/demo/ZhiHuDaily-React-Native/node_modules/react-native-viewpager/ViewPager.js: Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25` (211:40)
  209 |   },
  210 | 
> 211 |   _getPage(pageIdx: number, loop = false: boolean) {
      |                                         ^
  212 |     var dataSource = this.props.dataSource;
  213 |     var pageID = dataSource.pageIdentities[pageIdx];
  214 |     return (
    at Parser.pp$5.raise (/Users/gongzelong/Android/demo/ZhiHuDaily-React-Native/node_modules/babylon/lib/index.js:4333:13)
    at Parser.parseMaybeDefault (/Users/gongzelong/Android/demo/ZhiHuDaily-React-Native/node_modules/babylon/lib/index.js:5635:14)
    at Parser.pp$2.parseBindingList (/Users/gongzelong/Android/demo/ZhiHuDaily-React-Native/node_modules/babylon/lib/index.js:3037:22)
    at Parser.pp$3.parseMethod (/Users/gongzelong/Android/demo/ZhiHuDaily-React-Native/node_modules/babylon/lib/index.js:4053:22)
    at Parser.pp$3.parseObjPropValue (/Users/gongzelong/Android/demo/ZhiHuDaily-React-Native/node_modules/babylon/lib/index.js:3976:10)
    at Parser.parseObjPropValue (/Users/gongzelong/Android/demo/ZhiHuDaily-React-Native/node_modules/babylon/lib/index.js:5604:13)
    at Parser.pp$3.parseObj (/Users/gongzelong/Android/demo/ZhiHuDaily-React-Native/node_modules/babylon/lib/index.js:3950:10)
    at Parser.pp$3.parseExprAtom (/Users/gongzelong/Android/demo/ZhiHuDaily-React-Native/node_modules/babylon/lib/index.js:3639:19)
    at Parser.parseExprAtom (/Users/gongzelong/Android/demo/ZhiHuDaily-React-Native/node_modules/babylon/lib/index.js:6591:22)
    at Parser.pp$3.parseExprSubscripts (/Users/gongzelong/Android/demo/ZhiHuDaily-React-Native/node_modules/babylon/lib/index.js:3414:19)
See logs /var/folders/gf/hgd91n6x5v73ct9dvhr379500000gn/T/react-packager.log
    at SocketClient._handleMessage (/Users/gongzelong/Android/demo/ZhiHuDaily-React-Native/node_modules/react-native/packager/react-packager/src/SocketInterface/SocketClient.js:139:23)
    at BunserBuf.<anonymous> (/Users/gongzelong/Android/demo/ZhiHuDaily-React-Native/node_modules/react-native/packager/react-packager/src/SocketInterface/SocketClient.js:53:42)
    at emitOne (events.js:96:13)
    at BunserBuf.emit (events.js:188:7)
    at BunserBuf.process (/Users/gongzelong/Android/demo/ZhiHuDaily-React-Native/node_modules/bser/index.js:292:10)
    at /Users/gongzelong/Android/demo/ZhiHuDaily-React-Native/node_modules/bser/index.js:247:12
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
:app:bundleDebugJsAndAssets FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:bundleDebugJsAndAssets'.
> Process 'command 'react-native'' finished with non-zero exit value 1

* 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: 1 mins 3.71 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
zelongg commented 7 years ago

My node.js version is v6.9.1 ➜ ZhiHuDaily-React-Native git:(master) node --version v6.9.1 ➜ ZhiHuDaily-React-Native git:(master)

zelongg commented 7 years ago

I change the below _getPage(pageIdx: number, loop = false: boolean) { to

_getPage(pageIdx: number, loop: boolean = false) {

It still doesn't work.

Oh, it make the build error disappear. But when opening the android app, I got the below.

image

zelongg commented 7 years ago

Update:

I tried to delete node_modules and install everything again. And it worked. image

Here is my reference. https://github.com/xotahal/react-native-material-ui/issues/26

zelongg commented 7 years ago

Plus, I also add the lines in 'ZhiHuDaily-React-Native/android/build.gradle'.

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

https://github.com/facebook/react-native/issues/10140 http://facebook.github.io/react-native/docs/integration-with-existing-apps.html

ScottYang36 commented 6 years ago

Does anyone know how to handle it? caught error Error: SyntaxError: C:/Code/MyProject/ZhiHuDaily-React-Native-master/ZhiHuDaily-React-Native-master/node_modules/react-native-viewpager/ViewPager.js: Type annotations must come before default assignments, e.g. instead of age = 25: number use age: number = 25 (211:40) 209 | }, 210 | > 211 | _getPage(pageIdx: number, loop = false: boolean) { | ^ 212 | var dataSource = this.props.dataSource; 213 | var pageID = dataSource.pageIdentities[pageIdx]; 214 | return ( at Parser.pp$5.raise (C:\Code\MyProject\ZhiHuDaily-React-Native-master\ZhiHuDaily-React-Native-master\node_modules\babylon\lib\index.js:4454:13) at Parser.parseMaybeDefault (C:\Code\MyProject\ZhiHuDaily-React-Native-master\ZhiHuDaily-React-Native-master\node_modules\babylon\lib\index.js:6284:14) at Parser.pp$2.parseBindingList (C:\Code\MyProject\ZhiHuDaily-React-Native-master\ZhiHuDaily-React-Native-master\node_modules\babylon\lib\index.js:3121:22) at Parser.pp$3.parseMethod (C:\Code\MyProject\ZhiHuDaily-React-Native-master\ZhiHuDaily-React-Native-master\node_modules\babylon\lib\index.js:4178:22) at Parser.pp$3.parseObjectMethod (C:\Code\MyProject\ZhiHuDaily-React-Native-master\ZhiHuDaily-React-Native-master\node_modules\babylon\lib\index.js:4097:10) at Parser.pp$3.parseObjPropValue (C:\Code\MyProject\ZhiHuDaily-React-Native-master\ZhiHuDaily-React-Native-master\node_modules\babylon\lib\index.js:4140:19)

ScottYang36 commented 6 years ago

My dev-os is Win-10, but seems like this project need dependency - fsevents which is on OSX.

so after "npm install" will post below warnings "npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.0 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.0: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})"

ScottYang36 commented 6 years ago

modify: _getPage(pageIdx: number, loop = false: boolean) { to _getPage(pageIdx: number, loop: boolean = false) {

build failed solved.

gongzelong0718 commented 6 years ago

Plz ignore this. Update with personal github account