Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to build release APK and IOS on RN v56 #20882

Closed
abartolo opened this issue Aug 28, 2018 · 17 comments
Closed

Failing to build release APK and IOS on RN v56 #20882

abartolo opened this issue Aug 28, 2018 · 17 comments
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@abartolo
Copy link

Hello,

I am having issues building release APK and IOS after upgrading to v56. Dev builds work as expected on both android and ios emulators.

I am seeing the following error below only on release builds.

Error

08-27 20:47:42.675 23560-23586/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
    Process: miPrivateApp.main, PID: 23560
    com.facebook.react.common.JavascriptException: Invalid attempt to spread non-iterable instance, stack:
    nonIterableSpread@11:3941
    toConsumableArray@11:4436
    <unknown>@868:215
    c@2:822
    i@2:464
    t@2:324
    <unknown>@865:520
    c@2:822
    i@2:464
    t@2:324
    <unknown>@864:338
    c@2:822
    i@2:464
    t@2:324
    <unknown>@857:235
    c@2:822
    i@2:464
    t@2:324
    <unknown>@458:296
    c@2:822
    i@2:464
    t@2:324
    <unknown>@384:197
    c@2:822
    i@2:464
    t@2:324
    <unknown>@309:246
    c@2:822
    i@2:464
    t@2:324
    <unknown>@12:77
    c@2:822
    i@2:394
    t@2:324
    global code@1026:8
    
        at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError(ExceptionsManagerModule.java:54)
        at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException(ExceptionsManagerModule.java:38)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160)
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
        at android.os.Handler.handleCallback(Handler.java:789)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
        at android.os.Looper.loop(Looper.java:164)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
        at java.lang.Thread.run(Thread.java:764)

.babelrc

{
  "presets": ["react-native", "@babel/flow"],
  "env": {
    "production": {
      "plugins": ["transform-remove-console"]
    }
  }
}

Package.json

{
  "name": "AppleJeans",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "flow": "flow",
    "flow-full": "flow --show-all-errors > tmp-flow-results.log",
    "flow-stop": "flow stop",
    "eslint": "eslint 'src/**'",
    "eslint-fix": "eslint 'src/**' --fix"
  },
  "dependencies": {
    "babel-plugin-transform-remove-console": "^6.9.2",
    "cloudinary-core": "^2.4.0",
    "lodash": "^4.17.5",
    "moment": "^2.20.1",
    "pouchdb-adapter-react-native-sqlite": "^1.0.3",
    "pouchdb-find": "^6.4.3",
    "pouchdb-react-native": "^6.4.0",
    "prop-types": "^15.6.1",
    "react": "16.4.1",
    "react-native": "0.56.0",
    "react-native-action-button": "^2.8.4",
    "react-native-app-intro": "^1.1.5",
    "react-native-color-picker": "^0.4.0",
    "react-native-device-info": "0.21.5",
    "react-native-display": "^1.0.8",
    "react-native-easy-grid": "0.2.0",
    "react-native-elements": "^0.19.0",
    "react-native-hideable-view": "^1.0.3",
    "react-native-keep-awake": "3.1.0",
    "react-native-keyboard-aware-scroll-view": "^0.4.3",
    "react-native-material-dropdown": "^0.7.2",
    "react-native-material-textfield": "^0.12.0",
    "react-native-modal": "6.4.0",
    "react-native-modal-datetime-picker": "^4.13.0",
    "react-native-orientation": "git+https://github.com/leandrosimoes/react-native-orientation#master",
    "react-native-popup-menu": "0.13.2",
    "react-native-snackbar": "0.5.0",
    "react-native-step-indicator": "^0.0.7",
    "react-native-tab-view": "^0.0.74",
    "react-native-uuid": "^1.4.9",
    "react-native-vector-icons": "^4.5.0",
    "react-navigation": "1.5.0",
    "react-redux": "^5.0.6",
    "redux": "^3.7.2"
  },
  "devDependencies": {
    "@babel/preset-flow": "^7.0.0-rc.1",
    "babel-eslint": "^8.2.6",
    "babel-jest": "23.4.0",
    "babel-plugin-transform-regenerator": "^6.26.0",
    "babel-preset-react-native": "^5",
    "eslint": "^5.4.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.1.1",
    "eslint-plugin-react": "^7.11.1",
    "flow-bin": "^0.75.0",
    "jest": "23.4.0",
    "react-test-renderer": "16.4.1",
    "reactotron-react-native": "2.0.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

React Native Info

  React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
      Memory: 266.08 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
      Yarn: 1.7.0 - /usr/local/bin/yarn
      npm: 5.6.0 - ~/.nvm/versions/node/v8.11.3/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
      Android SDK:
        Build Tools: 23.0.1, 25.0.2, 26.0.1, 26.0.3, 27.0.3
        API Levels: 23, 25, 26, 27
    IDEs:
      Android Studio: 3.1 AI-173.4720617
      Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.4.1 => 16.4.1
      react-native: 0.56.0 => 0.56.0
    npmGlobalPackages:
      react-native-cli: 2.0.1
@react-native-bot react-native-bot added the Platform: iOS iOS applications. label Aug 28, 2018
@abartolo
Copy link
Author

Bot tagged as IOS but the error is for Android.

@tobiloba23
Copy link

Great, hopefully we get a response very soon

@brenohq
Copy link

brenohq commented Aug 30, 2018

same issue here

@raghuureddy
Copy link

raghuureddy commented Aug 31, 2018

same issue, works fine on Debug, but fails on release build on android.

image

@kelset kelset added 📋No Repro Steps and removed Platform: iOS iOS applications. labels Aug 31, 2018
@tobiloba23
Copy link

Just to verify, does running
react-native run-android -- --stacktrace variant=release
work on your local system, because it works fine on mine?

@raghuureddy
Copy link

react-native run-android -- --stacktrace variant=release

The above command is installing the debug version of the app on the simulator and that's why might be working for you.

I tried the below command to install the release apk for which it is failing.
react-native run-android --variant=release

@tobiloba23
Copy link

Okay thanks for the clarification you are absolutely right, doesn't work

@abartolo
Copy link
Author

@tobiloba23 @raghuureddy @brenohq Any chance you guys are using "react-navigation": "1.5.0" or any 1.X version?

Initially I thought my project was set incorrectly but after copying/running the index.js/App,js file from a fresh v56 app, it runs in production build. So this leads me to believe a library we are using isn't compatible with Babel 7.

@raghuureddy
Copy link

@abartolo mine is

"react-navigation": "^2.11.2"

@abartolo
Copy link
Author

@raghuureddy Thanks, I guess that was not the issue. Currently I am trying to add polyfills or anything suggested in #19827 to see if this helps.

@raghuureddy
Copy link

If it helps, the crash occurs if i select any item in "react-native-multiple-select" component. Only in release mode.

@abartolo
Copy link
Author

abartolo commented Aug 31, 2018

@raghuureddy Hmm I don't have that library. But I was able to pass this error adding the following code to my index.js file.

After adding below I get another error "undefined is not an object (evaluating 'r.default')"

index.js

import "@babel/polyfill";

import {AppRegistry} from "react-native";
.....

package.json
{
"@babel/polyfill": "^7.0.0-beta.47"
}

@abartolo
Copy link
Author

abartolo commented Sep 4, 2018

@anyone who is having this issue or similar. The error above that I posed was due to 2 errors below.

  1. It was breaking due to the following code:

Good w/ Babel 6
Bad w/ Babel 7
const minutesPerPeriod = [...Array(21).keys()].slice(1).map(num => num.toString());

Fix
const minutesPerPeriod = Array(21).fill().slice(1).map((num, i) => i.toString());

  1. I then got the following error below after fixing my code.

Error
Fatal Exception: com.facebook.react.common.JavascriptException: TypeError: undefined is not an object (evaluating 'r.default')

This was fixed after reading aksonov/react-native-router-flux#3124 (comment) and applying the following PR react-navigation/react-navigation#4699 to my local node_modules.

cc: @raghuureddy @tobiloba23 @brenohq

@abartolo
Copy link
Author

abartolo commented Sep 4, 2018

Note - I had to all my imports and slowly uncomment/build release app until I pinpointed where the code was breaking during babel compiling.

@raghuureddy
Copy link

in my case it was due to empty object spread and I have added a condition to check for empty and below is my pull request.

react-native-multiple-select Pull request

Its working now in release mode as well.

@stale
Copy link

stale bot commented Dec 4, 2018

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 4, 2018
@stale
Copy link

stale bot commented Dec 11, 2018

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Dec 11, 2018
@facebook facebook locked as resolved and limited conversation to collaborators Dec 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

6 participants