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

App Crashing without any error when I'm trying to upload an Image #4097

Closed
4 of 9 tasks
papuruth opened this issue Aug 15, 2020 · 5 comments · Fixed by #5335
Closed
4 of 9 tasks

App Crashing without any error when I'm trying to upload an Image #4097

papuruth opened this issue Aug 15, 2020 · 5 comments · Fixed by #5335
Labels
plugin: storage Firebase Cloud Storage

Comments

@papuruth
Copy link

Issue

App Crashing without any error when I'm trying to upload an Image. I have followed all the tutorials and also the official example provided on react-native-firebase-storage getting started page. But still no luck also I'm getting error of Please use gs:// URL for storage bucket.

Project Files

Javascript

Click To Expand

package.json:

{
  "name": "construction",
  "version": "2.1.0",
  "private": false,
  "scripts": {
    "start": "react-native start",
    "test": "jest",
    "test:update": "jest -u",
    "test:coverage": "jest --coverage",
    "run:ios": "react-native run-ios",
    "run:android": "react-native run-android",
    "build:prod": "react-native run-android --variant=release",
    "build:debug": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/",
    "gradle:build": "cd android && ./gradlew assembleDebug",
    "lint": "./node_modules/eslint/bin/eslint.js src",
    "lint:fix": "./node_modules/eslint/bin/eslint.js src --fix",
    "prettier:fix": "prettier --write **/**",
    "devtools": "react-devtools",
    "flow": "./node_modules/flow-bin/cli.js",
    "e2e:build": "detox build --configuration ios.sim.debug",
    "e2e:test": "detox test --configuration ios.sim.debug"
  },
  "dependencies": {
    "@react-native-community/art": "^1.2.0",
    "@react-native-community/async-storage": "^1.11.0",
    "@react-native-community/datetimepicker": "^2.5.0",
    "@react-native-community/masked-view": "^0.1.9",
    "@react-native-community/netinfo": "^5.9.6",
    "@react-native-firebase/app": "^8.3.0",
    "@react-native-firebase/storage": "^7.3.1",
    "@react-navigation/bottom-tabs": "^5.2.6",
    "@react-navigation/drawer": "^5.4.1",
    "@react-navigation/native": "^5.6.1",
    "@react-navigation/stack": "^5.2.10",
    "axios": "^0.19.2",
    "global": "^4.4.0",
    "i18n-js": "^3.2.1",
    "jetifier": "^1.6.5",
    "lodash": "^4.17.13",
    "metro-config": "^0.59.0",
    "moment": "^2.24.0",
    "moment-with-locales-es6": "^1.0.1",
    "prop-types": "^15.7.2",
    "react": "16.13.1",
    "react-native": "0.63.2",
    "react-native-calendars": "1.265.0",
    "react-native-camera": "^3.31.0",
    "react-native-elements": "^2.0.2",
    "react-native-fontawesome-pro": "^2.1.0",
    "react-native-gesture-handler": "^1.5.0",
    "react-native-gifted-chat": "^0.11.3",
    "react-native-image-picker": "^2.3.3",
    "react-native-lightbox": "^0.8.0",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-loading-spinner-overlay": "^1.1.0",
    "react-native-localize": "^1.3.1",
    "react-native-modal": "^9.0.0",
    "react-native-modal-datetime-picker": "^6.0.0",
    "react-native-paper": "^3.1.1",
    "react-native-progress": "^4.1.2",
    "react-native-reanimated": "^1.8.0",
    "react-native-safe-area-context": "^0.7.3",
    "react-native-screens": "^2.5.0",
    "react-native-svg": "^12.1.0",
    "react-native-svg-transformer": "^0.14.3",
    "react-native-ui-lib": "^3.39.0",
    "react-native-vector-icons": "^6.6.0",
    "react-navigation": "^4.4.0",
    "react-redux": "^6.0.1",
    "recompose": "^0.30.0",
    "redux": "^4.0.1",
    "redux-logger": "^3.0.6",
    "redux-persist": "^5.10.0",
    "redux-promise": "^0.6.0",
    "redux-react-native-session": "^1.0.7",
    "redux-react-session": "^2.6.1",
    "redux-saga": "^1.1.3",
    "redux-thunk": "^2.3.0",
    "victory-native": "^31.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.5.0",
    "@babel/preset-flow": "^7.0.0",
    "@babel/runtime": "^7.5.0",
    "@react-native-community/eslint-config": "^0.0.3",
    "babel-eslint": "^10.0.1",
    "babel-jest": "^24.1.0",
    "danger": "^7.0.2",
    "enzyme": "^3.7.0",
    "enzyme-adapter-react-16": "^1.7.0",
    "eslint": "^5.9.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-config-prettier": "^6.11.0",
    "eslint-import-resolver-alias": "^1.1.2",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.1.2",
    "eslint-plugin-react": "^7.11.1",
    "flow-bin": "^0.105.0",
    "jest": "^24.1.0",
    "jsdom": "13.0.0",
    "jsdom-global": "3.0.2",
    "metro-react-native-babel-preset": "^0.51.1",
    "plop": "^2.2.0",
    "prettier": "^1.16.1",
    "react-addons-test-utils": "^15.6.2",
    "react-devtools": "3",
    "react-dom": "^16.6.3",
    "react-test-renderer": "16.8.1",
    "sinon": "^7.1.1"
  },
  "jest": {
    "preset": "react-native",
    "transform": {
      "^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
    },
    "collectCoverage": true,
    "collectCoverageFrom": [
      "src/**/*.{js,jsx}",
      "!**/node_modules/**",
      "!android/**",
      "!ios/**",
      "!assets/**"
    ],
    "coverageDirectory": "jest_coverage",
    "setupFiles": [
      "./jest-setup.js"
    ],
    "testPathIgnorePatterns": [
      "/node_modules/",
      "/e2e/"
    ]
  },
  "detox": {
    "configurations": {
      "ios.sim.debug": {
        "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/ReactNativeStarter.app",
        "build": "xcodebuild -UseModernBuildSystem=NO -project ios/ReactNativeStarter.xcodeproj -scheme ReactNativeStarter -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
        "type": "ios.simulator",
        "name": "iPhone XS"
      },
      "ios.sim.release": {
        "binaryPath": "ios/build/Build/Products/Release-iphonesimulator/ReactNativeStarter.app",
        "build": "xcodebuild -UseModernBuildSystem=NO -project ios/ReactNativeStarter.xcodeproj -scheme ReactNativeStarter -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
        "type": "ios.simulator",
        "name": "iPhone 7"
      }
    },
    "test-runner": "jest"
  }
}

firebase.json for react-native-firebase v6:

# N/A

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
# N/A

AppDelegate.m:

// N/A


Android

Click To Expand

Have you converted to AndroidX?

  • my application is an AndroidX application?
  • I am using android/gradle.settings jetifier=true for Android compatibility?
  • I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
    }
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com'
            name 'Google'
        }
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.3.0")
        classpath('com.google.gms:google-services:4.3.3')
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
        maven { url "https://maven.google.com" } 
    }
}

android/app/build.gradle:

// N/A

android/settings.gradle:

apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js",
    enableHermes: true,
]

apply from: "../../node_modules/react-native/react.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

/**
 * The preferred build flavor of JavaScriptCore.
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US.  Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'
/**
 * Whether to enable the Hermes VM.
 *
 * This should be set on project.ext.react and mirrored here.  If it is not set
 * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
 * and the benefits of using Hermes will therefore be sharply reduced.
 */
def enableHermes = project.ext.react.get("enableHermes", true);

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.construction"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        missingDimensionStrategy 'react-native-camera', 'general'
        multiDexEnabled true

    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    implementation "com.facebook.react:react-native:+"  // From node_modules
    def multidex_version = "2.0.1"
    implementation 'androidx.multidex:multidex:$multidex_version'
    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

MainApplication.java:

package com.construction;

import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;

import com.facebook.react.ReactApplication;
import com.oblador.vectoricons.VectorIconsPackage;
import com.reactcommunity.rnlocalize.RNLocalizePackage;
import com.BV.LinearGradient.LinearGradientPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import androidx.multidex.MultiDexApplication;
import java.lang.reflect.InvocationTargetException;
import java.util.List;

public class MainApplication extends MultiDexApplication implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();

      // Packages that cannot be autolinked yet can be added manually here, for example:
      // packages.add(new MyReactNativePackage());

      return packages;
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
    initializeFlipper(this); // Remove this line if you don't want Flipper enabled
  }

  /**
   * Loads Flipper in React Native templates.
   *
   * @param context
   */
  private static void initializeFlipper(Context context) {
    if (BuildConfig.DEBUG) {
      try {
        /*
         We use reflection here to pick up the class that initializes Flipper,
        since Flipper library is not available in release mode
        */
        Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
        aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
      } catch (ClassNotFoundException e) {
        e.printStackTrace();
      } catch (NoSuchMethodException e) {
        e.printStackTrace();
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      } catch (InvocationTargetException e) {
        e.printStackTrace();
      }
    }
  }
}

AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.construction">

  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.CAMERA" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

  <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
    <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>


Environment

Click To Expand

react-native info output:

 System:
    OS: Windows 10 10.0.19041
    CPU: (8) x64 AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx
    Memory: 542.44 MB / 5.88 GB
  Binaries:
    Node: 12.16.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.4 - C:\Users\d-Evil\AppData\Roaming\npm\yarn.CMD
    npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
  IDEs:
    Android Studio: Version  4.0.0.0 AI-193.6911.18.40.6514223
  Languages:
    Java: 11.0.7 - /cygdrive/c/Program Files/Java/jdk-11.0.7/bin/javac
    Python: 2.7.17 - /cygdrive/c/Python27/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1
    react-native: 0.63.2 => 0.63.2
  npmGlobalPackages:
    *react-native*: Not Found

  • Platform that you're experiencing the issue on:
    • iOS
    • [x ] Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:
    • 8.3.0
  • Firebase module(s) you're using that has the issue:
    • Cloud Storage
  • Are you using TypeScript?
    • N


@andersonaddo
Copy link
Contributor

Mind showing some code? Show us a snippet of the upload code please.

@andersonaddo andersonaddo added the plugin: storage Firebase Cloud Storage label Aug 15, 2020
@andersonaddo
Copy link
Contributor

Also if you aren't getting crash logs from the emulator, maybe test it on a real device and check logcat

@papuruth
Copy link
Author

Thanks for replying. But it's solved by clean building the app.

@mikehardy
Copy link
Collaborator

npx react-native-clean-project should be a part of CI for any react-native app, IMHO

@mikehardy mikehardy reopened this May 16, 2021
@mikehardy
Copy link
Collaborator

Believe it or not I just ran into this myself. I don't use storage as a main use case but I'm adding support to the library for the storage emulator and if I pass certain types of junk data in, it would crash native and take the app down in an uncatchable way with this exact exception.

mikehardy added a commit that referenced this issue May 17, 2021
…reject

Previously if you sent undefined in as a URL, or a URL that was unparseable,
the native android code would throw IllegalArgumentException, which would crash
the app with a native exception. Now those exceptions are caught and bubbled up
to the javascript layer correctly as a promise rejection

Fixes #4097
mikehardy added a commit that referenced this issue May 18, 2021
…reject

Previously if you sent undefined in as a URL, or a URL that was unparseable,
the native android code would throw IllegalArgumentException, which would crash
the app with a native exception. Now those exceptions are caught and bubbled up
to the javascript layer correctly as a promise rejection

Fixes #4097
mikehardy added a commit that referenced this issue May 18, 2021
…reject

Previously if you sent undefined in as a URL, or a URL that was unparseable,
the native android code would throw IllegalArgumentException, which would crash
the app with a native exception. Now those exceptions are caught and bubbled up
to the javascript layer correctly as a promise rejection

Fixes #4097
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: storage Firebase Cloud Storage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants