question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Release APK crash immediately on launch - React Native ( Version 0.58.4)

See original GitHub issue

šŸ› Bug Report

The android version runs perfectly in debug mode using android studio emulator. However, the release version of the apk crashes immediately when launched.

To Reproduce

Steps to reproduce the behavior.

Reproducible Demo

react-native init Demo
cd AwesomeProject

After this Just install following:

npm i --save react-native-crypto
npm i bitcore-lib --save
npm i --save react-native-randombytes
react-native link react-native-randombytes
npm i --save-dev tradle/rn-nodeify
./node_modules/.bin/rn-nodeify --hack --install

rn-nodeify will create a shim.js in the project root directory

import ā€˜./shim.jsā€™ file in aap.js

react-native run-android

It runs perfectly in debug mode. I have created signed apk it gets created without any error also installed without error but when i open, it crashes

Expected Behavior

The app should run without crashing. App crashes on launch, logcat throws this error:

02-09 11:18:38.980 13627-13645/com.productionbuild E/ReactNativeJS: undefined is not a function (evaluating 'n.fill(255)')
02-09 11:18:38.995 13627-13645/com.productionbuild E/ReactNativeJS: Module AppRegistry is not a registered callable module (calling runApplication)
02-09 11:18:39.007 13627-13646/com.productionbuild E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
    Process: com.productionbuild, PID: 13627
    com.facebook.react.common.JavascriptException: undefined is not a function (evaluating 'n.fill(255)'), stack:
    exports@527:162
    <unknown>@526:54
    _@2:1514
    d@2:967
    o@2:435
    <unknown>@525:59
    _@2:1514
    d@2:967
    o@2:435
    <unknown>@503:548
    _@2:1514
    d@2:967
    o@2:435
    <unknown>@355:242
    _@2:1514
    d@2:967
    o@2:435
    <unknown>@11:58
    _@2:1514
    d@2:897
    o@2:435
    global code@566:4
    
        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:158)
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
        at android.os.Looper.loop(Looper.java:148)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
        at java.lang.Thread.run(Thread.java:818)

Code Example

import React, { Component } from "react";
import { Platform, StyleSheet, Text, View } from "react-native";
import "./shim.js";
import bitcoin from "bitcore-lib";
// import { Buffer } from "safe-buffer";
// var Buffer;
// if (typeof global !== "undefined") {
//   var Buffer = require("safe-buffer/").Buffer;
//   global.Buffer = Buffer; // TODO just use global Buffer
// }

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

  generateBitcoinKeys() {
    var privateKey = new bitcoin.PrivateKey(bitcoin.Networks.testnet);
    var publicKey = privateKey.toPublicKey();
    var address = publicKey.toAddress(bitcoin.Networks.testnet);
    return {
      Address: address.toString(),
      privateKey: privateKey.toString(),
      publicKey: publicKey.toString()
    };
  }
  render() {
    var aa = this.generateBitcoinKeys();
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>Welcome to React Native!</Text>
        <Text style={styles.instructions}>bitcoin address: {aa.Address}</Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: "center",
    alignItems: "center",
    backgroundColor: "#F5FCFF"
  },
  welcome: {
    fontSize: 20,
    textAlign: "center",
    margin: 10
  },
  instructions: {
    textAlign: "center",
    color: "#333333",
    marginBottom: 5
  }
});

Environment

Platform: Android React Native Environment Info: System: Windows 10 CPU: x64 IntelĀ® Coreā„¢ i5- CPU M 520 @ 2.40GHz 2.39 GHz

Binaries: Node : 8.11.3 npm: 6.4.1

IDEs: Android Studio: 3.2 AI-181.5540.7.32.5014246 VS Code: 1.31.0 npmPackages: react: 16.6.3 => 16.6.3 react-native: 0.58.4 => 0.58.4 npmGlobalPackages: react-native-cli: 2.0.1 react-native-git-upgrade: 0.2.7

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:25
  • Comments:41

github_iconTop GitHub Comments

31reactions
mathew3commented, Jun 10, 2019

Try to use adb logcat *:E, super helpful if the error is not JS related

26reactions
quietbitscommented, Apr 28, 2019

Iā€™m getting these crashes with RN version 0.59.5 with APK, too. It works fine when building, but APK crashes right after opening the app. Can reproduce this on a real device (OnePlus 3, Android version 8.0.0), as well as on emulators (Pixel 3 XL with 64 bit Android 9.0 and Nexus 6P with Android 7.1.1). I can confirm that this is an issue even with a clean project created with react-native init. Other solutions mentioned here have not worked for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-native (Signed) release apk keeps crashing in device
You can get one from your device by plugging your phone into your computer, open the app so it crashes, then run adb...
Read more >
Fixing React-Native android release build - wesionaryTEAM
Android release build crashes on launch but works fine in development mode. After months of research and development, your app is finally ready...
Read more >
React Native Android release build crash on device - Medium
Open a terminal or command prompt and navigate to your project's root folder. And execute command below. It will delete any existing 'index....
Read more >
React Native Android Staging Build Crashes On Startup
However the release version of the apk crashes immediately when launched. ... Release APK crash immediately on launch React Native Version 0.58.4.
Read more >
React-native app crashes on launch android
Release APK crash immediately on launch - React Native (Version 0.58.4) Ā· Issue #23352 Ā· facebook/react-native Ā· GitHub Bug Report The android versionĀ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found