facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
117.12k stars 24.07k forks source link

App is crashing on launch - only on Release build #17276

Closed adrianstrahan closed 6 years ago

adrianstrahan commented 6 years ago

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment: OS: macOS High Sierra 10.13.2 Node: 8.2.1 Yarn: Not Found npm: 5.5.1 Watchman: 2.9.8 Xcode: Xcode 9.2 Build version 9C40b Android Studio: Not Found

Packages: (wanted => installed) react: 16.0.0 => 16.0.0 react-native: 0.50.3 => 0.50.3

Steps to Reproduce

react-native run-ios --configuration Release

Also getting this from AppStore review after uploading to AppStore

Expected Behavior

App should not crash on launch. This works fine in local testing on device and in Simulator

Actual Behavior

App crashes on launch

Here is the crash log:

Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Triggered by Thread: 1

Application Specific Information: abort() called

Filtered syslog: None found

Last Exception Backtrace: (0x183d32364 0x182f78528 0x183d322ac 0x1006e8780 0x1006e6444 0x183d39cd0 0x183c1856c 0x183c1d01c 0x1006f98f8 0x100739618 0x100739378 0x1836aea54 0x1836aea14 0x1836b896c 0x1836b92fc 0x1836b9d20 0x1836c203c 0x183956f1c 0x183956b6c)

Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0: 0 libsystem_kernel.dylib 0x0000000183823568 0x183822000 + 5480 1 libsystem_kernel.dylib 0x00000001838233e0 0x183822000 + 5088 2 CoreFoundation 0x0000000183cda308 0x183bec000 + 975624 3 CoreFoundation 0x0000000183cd7ed4 0x183bec000 + 966356 4 CoreFoundation 0x0000000183bf7e58 0x183bec000 + 48728 5 GraphicsServices 0x0000000185aa4f84 0x185a9a000 + 44932 6 UIKit 0x000000018d27767c 0x18d204000 + 472700 7 Flourishzone 0x00000001006ac588 0x1006a4000 + 34184 8 libdyld.dylib 0x000000018371456c 0x183713000 + 5484

Thread 1 name: Dispatch queue: com.facebook.react.ExceptionsManagerQueue Thread 1 Crashed: 0 libsystem_kernel.dylib 0x00000001838442e8 0x183822000 + 140008 1 libsystem_pthread.dylib 0x00000001839592f8 0x183956000 + 13048 2 libsystem_c.dylib 0x00000001837b2fbc 0x183750000 + 405436 3 libc++abi.dylib 0x0000000182f4f068 0x182f4d000 + 8296 4 libc++abi.dylib 0x0000000182f4f210 0x182f4d000 + 8720 5 libobjc.A.dylib 0x0000000182f78810 0x182f70000 + 34832 6 libc++abi.dylib 0x0000000182f6754c 0x182f4d000 + 107852 7 libc++abi.dylib 0x0000000182f66ea8 0x182f4d000 + 106152 8 libobjc.A.dylib 0x0000000182f7865c 0x182f70000 + 34396 9 Flourishzone 0x0000000100739764 0x1006a4000 + 612196 10 Flourishzone 0x0000000100739378 0x1006a4000 + 611192 11 libdispatch.dylib 0x00000001836aea54 0x1836ad000 + 6740 12 libdispatch.dylib 0x00000001836aea14 0x1836ad000 + 6676 13 libdispatch.dylib 0x00000001836b896c 0x1836ad000 + 47468 14 libdispatch.dylib 0x00000001836b92fc 0x1836ad000 + 49916 15 libdispatch.dylib 0x00000001836b9d20 0x1836ad000 + 52512 16 libdispatch.dylib 0x00000001836c203c 0x1836ad000 + 86076 17 libsystem_pthread.dylib 0x0000000183956f1c 0x183956000 + 3868 18 libsystem_pthread.dylib 0x0000000183956b6c 0x183956000 + 2924

irhtml commented 6 years ago

im also having this issue.

assertion failed: 17B1003 15C107: libxpc.dylib + 72226

edit: found this after digging through the logs.

*** Terminating app due to uncaught exception ’RCTFatalException: Unhandled JS Exception: undefined is not an object (evaluating ‘s.View.propTypes.style’)’, reason: ’Unhandled JS Exception: undefined is not an object (evaluating ’s.View.prop..., stack:

my issue is probably related to NativeBase and not RN: https://github.com/GeekyAnts/NativeBase/issues/851

massimopibiri commented 6 years ago

About the issue of @toppetoppe , I had the same and (for me worked in this way) the problem is that you still have old packages using PropTypes from React. Just update the packages at the last versions. Despite that, my application crashes without any error message. And that's terrible ! I don't know if it is the same case of this issue. If it is not the case, I'll open a new issue. in my case 'react-native run-android' works perfectly. During months I did the signed APK without problem (and react-native run-android --variant=release). Then, a few days ago, when it's time to give the final product, I had the bad surprise. The application doesn't create anymore the signed APK, wich shows BUILT SUCCESSFUL, but once installed in the smartphone it crashes when opening without any message.

capture2

If I try to build with AndroidStudio, it shows APK(s) generated successfully:

capture

the warnings in the LogCat are:

QtiTetherService/IpaWrapper: getStats(false)
NotificationService: notifications are disabled by AppOps for com.android.chrome
NotificationService: Suppressing notification from package com.android.chrome by user request.
power_metrics_r: type=1400 audit(0.0:11047): avc: denied { read } for name="mem" dev="debugfs" ino=122747 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:debugfs:s0 tclass=file permissive=0
power_metrics_r: type=1400 audit(0.0:11048): avc: denied { read } for name="mem" dev="debugfs" ino=122747 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:debugfs:s0 tclass=file permissive=0
NotificationService: notifications are disabled by AppOps for com.android.chrome
NotificationService: Suppressing notification from package com.android.chrome by user request.

The APK, once installed on the smart phone, does the same. When launched, it crashes without message. Important: despite the warnings of AndroidStudio, the pushnotifications works well in dev. In case it can help, I initialized the push notifications in the highter level component with a class like this:

import PushNotification from 'react-native-push-notification';
import { isNil } from 'lodash';
import Config from './config';
import { isAndroid } from '../functions/helpers';

export default class PushService {
  static init() {
    PushService.onNotification = (notification) => {
      if (isAndroid() && (!isNil(notification.subject) && notification.subject !== '')) {
        PushNotification.localNotification({
          title: notification.subject,
          message: notification.body,
          smallIcon: 'ic_launcher',
          tag: 'some_tag',
          group: "group"
        });
      }
    }
    PushService.onRegis = null;
    PushService.tab = null;
  }

  static setCallbacks(onRegis, onNotification) {
    PushService.onRegis = onRegis;
    PushService.onNotification = onNotification;
  }

  static configure() {
    PushNotification.configure({
      onRegister: (data) => {
        if (PushService.onRegis) {
          PushService.onRegis(data);
        }
      },
      onNotification: (notification) => {
        if (PushService.onNotification) {
          PushService.onNotification(notification);
        }
      },
      senderID: Config.senderID,
        // IOS ONLY (optional): default: all - Permissions to register.
        permissions: {
            alert: true,
            badge: true,
            sound: true
        },
        // Should the initial notification be popped automatically
        popInitialNotification: false,
      requestPermissions: false
    })
  }
}

PushService.init();

Here my package.json:

  "dependencies": {
    "axios": "^0.17.1",
    "crypto-js": "^3.1.9-1",
    "event-emitter": "^0.3.5",
    "lodash": "^4.17.4",
    "prop-types": "^15.6.0",
    "react": "16.2.0",
    "react-addons-update": "^15.6.2",
    "react-native": "0.51.0",
    "react-native-aws3": "0.0.8",
    "react-native-button": "^2.2.0",
    "react-native-camera": "^0.12.0",
    "react-native-carousel-control": "^2.0.1",
    "react-native-keychain": "^1.2.1",
    "react-native-linear-gradient": "^2.4.0",
    "react-native-push-notification": "^3.0.2",
    "react-native-router-flux": "^3.3.5a",
    "react-native-socket.io-client": "^1.4.8",
    "react-redux": "^5.0.6",
    "redux": "^3.7.2",
    "redux-persist": "^4.8.0",
    "redux-thunk": "^2.2.0",
    "socket.io-client": "^1.7.3",
    "socketio-jwt": "^4.5.0",
    "underscore": "^1.8.3",
    "uuid": "^3.0.1"
  },

My settings.grandle:

...
include ':react-native-push-notification'
project(':react-native-push-notification').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-push-notification/android')
include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')
include ':react-native-keychain'
project(':react-native-keychain').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keychain/android')
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
...

android/app/build.grandle:


...
android {
    compileSdkVersion 23
    buildToolsVersion "25.0.2"

    defaultConfig {
        applicationId "com.nameOfTheApp"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
...
dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile project(':react-native-push-notification')
    compile ('com.google.android.gms:play-services-gcm:8.1.0') {
        force = true;
    }
    compile project(':react-native-linear-gradient')
    compile project(':react-native-keychain')
    compile project(':react-native-camera')

grandle-wrapper-properties:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.nameOfTheApp"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <permission
        android:name="com.tricky.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission android:name="com.tricky.permission.C2D_MESSAGE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="22" />

    <application
      android:name=".MainApplication"
      android:allowBackup="true"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:theme="@style/AppTheme">
        <receiver
            android:name="com.google.android.gms.gcm.GcmReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <category android:name="com.nameOfTheApp" />
            </intent-filter>
        </receiver>

        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
        <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
        <service
            android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </service>
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>
</manifest>

MainApplication.java:

...
import com.oblador.keychain.KeychainPackage;
import com.lwansbrough.RCTCamera.RCTCameraPackage;
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;
import com.BV.LinearGradient.LinearGradientPackage;
...

    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new KeychainPackage(),
          new RCTCameraPackage(),
          new ReactNativePushNotificationPackage(),
          new LinearGradientPackage()
      );
...

android/build.grandle:

...

    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
...

I think is an issue with the last version of react-native, despite I adapted everything I had to do (I suppose).

adrianstrahan commented 6 years ago

So I still haven't managed to resolve this issue. I have gone through my code and updated any mention of View.propTypes.style to ViewPropTypes.style and removed any mention of importing PropTypes from React (importing it from 'prop-types' instead). My app works fine in the Simulator and on a device. But when I run it using:

react-native run-ios --configuration Release

the app crashes straight away. Is there any way of getting any decent debug information as to what is causing the crash?

I have trawled the internet for possible clues but haven't found anything of use.

I must say that this is the most infuriating issue I've ever come across - and I really have no clues as to how to resolve it. Having something work perfectly well in development but then consistently fail with the release build is utterly painful. This is preventing me from submitting my app to the App Store, making me wonder if RN is actually worth any of the effort.

wmcbain commented 6 years ago

I'm running into this issue as well and when I grep in my project for propTypes.style I can see that it's coming from internal react-native Libraries:

grep -r 'propTypes.style' .

./node_modules/react-native/Libraries/Experimental/SwipeableRow/SwipeableQuickActionButton.js:    imageStyle: Image.propTypes.style,
./node_modules/react-native/Libraries/Experimental/SwipeableRow/SwipeableQuickActionButton.js:    textStyle: Text.propTypes.style,
./node_modules/react-native/Libraries/Components/TextInput/TextInput.js:    style: Text.propTypes.style,
grep -R "View.propTypes" node_modules                                         
node_modules/react-native/Libraries/Lists/ListView/ListView.js:    ...ScrollView.propTypes,
node_modules/react-native/Libraries/Components/WebView/WebView.ios.js:    decelerationRate: ScrollView.propTypes.decelerationRate,
node_modules/react-native/Libraries/ReactNative/verifyPropTypes.js:  // ReactNative `View.propTypes` have been deprecated in favor of
node_modules/react-native/Libraries/ReactNative/requireNativeComponent.js:    // ReactNative `View.propTypes` have been deprecated in favor of
node_modules/react-native/Libraries/Animated/src/createAnimatedComponent.js:  // ReactNative `View.propTypes` have been deprecated in favor of
node_modules/react-native/ReactAndroid/src/androidTest/assets/AndroidTestBundle.js:  propTypes: babelHelpers.extends({}, ScrollView.propTypes, {
node_modules/react-native-fbsdk/js/FBLikeView.js:LikeView.propTypes = {
adrianstrahan commented 6 years ago

OK, so I had to leave my project for a few weeks while I worked on something else. I have just come back to it and have managed to resolve the issue.

For those who still have a similar issue, the key is to replace every use of View.propTypes.style with ViewPropTypes.style (and make sure that you include a import { ViewPropTypes } from 'react-native';at the top of the file).

@wmcbain 's comment helped me to identify the libraries I was using that haven't been updated yet.

You have to do this in any third-party libraries you use as well as in all your own code.

I hope this helps someone.

davebro commented 6 years ago

Thanks @adrianstrahan. For me it was two third-party libraries that were referencing PropTypes from react-native, as well as View.propTypes.style.

jakallergis commented 6 years ago

I had the same problem, both on android, and iOS, and only on production, the app would build successfully but on the device (or simulator) it would keep crashing on launch.

So i ran my project in xCode+Simulator using the release schema, and when the app crashed the xCode logs had this error:

babelHelpers.objectDestructuringEmpty is not a function.

So after some digging around I found out that when building for production release, babel tries to optimize everything in the JS code, but it doesn't handle empty destructuring well.

I had a const {} = something in my JS code, and after I removed it, the app went fully functional again.

keshk26 commented 6 years ago

Hi, my iOS app is crashing in release as well. I am in the process of upgrading from 0.48.4 to 0.54.

2018-04-01 18:53:15.710 [error][tid:com.facebook.react.JavaScript] undefined is not an object (evaluating 'u.View.propTypes.style') 2018-04-01 18:53:15.712 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: undefined is not an object (evaluating 'u.View.propTypes.style') libc++abi.dylib: terminating with uncaught exception of type NSException

"react": "^16.3.0-alpha.1", "react-native": "0.54.4"

I did run grep as seen above and got the following output. I am not using View.propTypes.style anywhere (other than a comment) but I am using ListView.propTypes.style. Does this matter? Any Ideas?

node_modules/react-native/Libraries/Lists/ListView/ListView.js:    ...ScrollView.propTypes,
node_modules/react-native/Libraries/Components/WebView/WebView.ios.js:    decelerationRate: ScrollView.propTypes.decelerationRate,
node_modules/react-native/Libraries/ReactNative/verifyPropTypes.js:  // ReactNative `View.propTypes` have been deprecated in favor of
node_modules/react-native/Libraries/ReactNative/requireNativeComponent.js:    // ReactNative `View.propTypes` have been deprecated in favor of
node_modules/react-native-swiper/README.md:  + Update: using PropTypes from prop-types and Change View.propTypes to ViewPropTypes
node_modules/react-native-autocomplete-input/index.js:    listStyle: ListView.propTypes.style,
node_modules/react-native-fbsdk/js/FBLikeView.js:LikeView.propTypes = {
node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareScrollView.js:    ...ScrollView.propTypes,
trickeyd commented 6 years ago

@keshk26 I am curious about this also.

sangdesigner commented 6 years ago

Im using ReactNative auto update my build is successful but when open app it crash any solution

Manish3323 commented 6 years ago

I have updated my dependencies by replacing View.propTypes with ViewPropTypes. my app is still crashes instantly in release version!!! Someone help.. I am uilding an app for Fifa 18 ... it is near.. need help ..its urgent.. everything is working fine in dev version. : ( link of my github code

craigdub commented 6 years ago

Anyone still having issues with this?

Manish3323 commented 6 years ago

@craigdub solved it using react-codemod transform scripts and jscodeshift ..!!! Set up codemod and use it to remove deprecated react.props types scripts for ReactNative-View-propTypes and React-PropTypes-to-prop-types of react-codemod did work for me!!

vaibhgupta09 commented 6 years ago

hello everyone i facing problem with react-native-fcm app is crashing when it initially open dependencies { compile project(':react-native-version-check') compile(project(":react-native-google-signin")){
exclude group: "com.google.android.gms" // very important\ } compile project(':react-native-fcm') compile project(':react-native-android-location-services-dialog-box') compile project(':react-native-fbsdk') compile project(':react-native-splash-screen') compile project(':react-native-keyevent') compile project(':react-native-fused-location') compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:26.0.1" compile "com.facebook.react:react-native:+" // From node_modules compile 'com.facebook.fresco:animated-gif:1.3.0' compile 'com.facebook.fresco:animated-base-support:1.3.0' compile 'com.google.android.gms:play-services-auth:15.0.1' } this dependencies i am using please help to solve this Thanks!

agrinko commented 5 years ago

@vaibhgupta09 , same for me, crashes even in debug mode, both on emulator and real device. Did you manage to fix it?

demarchisd commented 5 years ago

@craigdub solved it using react-codemod transform scripts and jscodeshift ..!!! Set up codemod and use it to remove deprecated react.props types scripts for ReactNative-View-propTypes and React-PropTypes-to-prop-types of react-codemod did work for me!!

Hey @Manish3323 ! Could you give more details on how you did that?

amit2908 commented 5 years ago

@wmcbain I have tried this, but I found "View.proptypes.style" in my code as well as in one of the third party library of stripe payment, 'Tipsi-Stripe'. It is in Card.js.html file.

I have changed it to ViewProptypes.style in js files but as Card.js.html is an HTML file, should I change it too?

haiau commented 5 years ago

In my case, when Release I got a message like: ... Thread 1 name: Dispatch queue: com.facebook.react.ExceptionsManagerQueue Thread 1 Crashed: ... This bug prevented me from submitting my app to AppStore Then I test all cases, and read the code carefully, I found that there is the getter in an undefined object. So maybe there are some bugs in JS code and it causes crashes.