Skip to content

RN 0.56.0 ANDROID crash on release mode: JSException: Can't find variable: Promise #20062

@yiky84119

Description

@yiky84119

Environment

React Native Environment Info:
System:
OS: macOS High Sierra 10.13.5
CPU: x64 Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz
Memory: 31.50 MB / 8.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 8.11.3 - /usr/local/bin/node
Yarn: 1.7.0 - /usr/local/bin/yarn
npm: 5.6.0 - /usr/local/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: 19.1.0, 21.1.2, 22.0.1, 23.0.1, 23.0.2, 23.0.3, 24.0.2, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.2, 27.0.3
API Levels: 19, 22, 23, 24, 25, 26, 27
IDEs:
Android Studio: 3.1 AI-173.4819257
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:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7

Description

update to 0.56.0, when run android on release mode, app crash .
java.lang.RuntimeException: com.facebook.react.devsupport.JSException: Can't find variable: Promise

i just found that, if using promise outside first Component class, on release mode it crash.

// run error: Can't find variable: Promise
let test = Promise.reject(new Error('registerApp required.'));
test.then(() => {
    console.log('test');
});

type Props = {};
export default class App extends Component<Props> {
  constructor(props) {
    super(props);

      // run ok
      // let test = Promise.reject(new Error('registerApp required.'));
      // test.then(() => {
      //     console.log('test');
      // });
  }
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>Welcome to React Native!</Text>
        <Text style={styles.instructions}>To get started, edit App.js</Text>
        <Text style={styles.instructions}>{instructions}</Text>
      </View>
    );
  }
}

Reproducible Demo

https://snack.expo.io/r1tfsO2fX

Activity

kelset

kelset commented on Jul 6, 2018

@kelset
Contributor

Closing this in favour of #19827 since the conversation seems to be moving forward over there

locked as resolved and limited conversation to collaborators on Jul 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @yiky84119@kelset@react-native-bot

        Issue actions

          RN 0.56.0 ANDROID crash on release mode: JSException: Can't find variable: Promise · Issue #20062 · facebook/react-native