Skip to content

[V2] Android app crash - custom backButton FileNotFoundException #4448

@andresfcamacho

Description

@andresfcamacho

Issue Description

When deploying the app to HockeyApp we're getting an app crash:

java.lang.RuntimeException: java.io.FileNotFoundException: No content provider: assets_images_androidback
    at com.reactnativenavigation.viewcontrollers.button.NavigationIconResolver$1.onError(NavigationIconResolver.java:36)
    at com.reactnativenavigation.utils.ImageLoader.loadIcon(ImageLoader.java:40)
    at com.reactnativenavigation.viewcontrollers.button.NavigationIconResolver.resolve(NavigationIconResolver.java:28)
    at com.reactnativenavigation.viewcontrollers.TitleBarButtonController.applyNavigationIcon(TitleBarButtonController.java:100)
    at com.reactnativenavigation.views.titlebar.TitleBar.setLeftButton(TitleBar.java:173)
    at com.reactnativenavigation.views.titlebar.TitleBar.setBackButton(TitleBar.java:156)
    at com.reactnativenavigation.views.topbar.TopBar.setBackButton(TopBar.java:209)
    at com.reactnativenavigation.presentation.StackPresenter.applyButtons(StackPresenter.java:265)
    at com.reactnativenavigation.presentation.StackPresenter.applyChildOptions(StackPresenter.java:134)
    at com.reactnativenavigation.viewcontrollers.stack.StackController.applyChildOptions(StackController.java:87)
    at com.reactnativenavigation.viewcontrollers.ViewController.lambda$onViewAppeared$0$ViewController(ViewController.java:199)
    at com.reactnativenavigation.viewcontrollers.ViewController$$Lambda$0.run
    at com.reactnativenavigation.viewcontrollers.ViewController.performOnParentController(ViewController.java:130)
    at com.reactnativenavigation.viewcontrollers.ViewController.onViewAppeared(ViewController.java:197)
    at com.reactnativenavigation.viewcontrollers.ChildController.onViewAppeared(ChildController.java:34)
    at com.reactnativenavigation.viewcontrollers.ComponentViewController.onViewAppeared(ComponentViewController.java:35)
    at com.reactnativenavigation.viewcontrollers.ViewController.onGlobalLayout(ViewController.java:249)
    at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:981)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2393)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1509)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7051)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927)
    at android.view.Choreographer.doCallbacks(Choreographer.java:702)
    at android.view.Choreographer.doFrame(Choreographer.java:638)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6692)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

We have an Android specific conditional in our index.js

import { AndroidBackArrow, BackIconBlack, XIconBlack, AndroidXIconBlack } from '../../../images'

const backArrowIcon = isIOS() ? BackIconBlack : AndroidBackArrow
...

Our images.js file has the actual requires:

const BackIconBlack = require('../assets/images/Back_Icon_Black.png')
const AndroidBackArrow = require('../assets/images/androidback.png')

I made the Android file lowercase after reading this SO: https://stackoverflow.com/questions/15320951/why-is-it-not-possible-to-use-uppercase-in-naming-resources-in-android

but it still does not work.

NOTE: We had this problem locally as well but found a workaround by putting the png in this directory:

/android/app/src/main/assets

and then in the images.js the require looked like this:

const AndroidBackArrow = require('../android/app/src/main/assets/androidback.png')

This only works locally it does not work when bundling an apk.

IOS works fine. No problems this is only an issue for Android.

[FILL THIS OUT]


Environment

  • React Native Navigation version: 2.0.2641
  • React Native version: 0.57.0
  • Platform(s) (iOS, Android, or both?): Android only
  • Device info (Simulator/Device? OS version? Debug/Release?):Device Release

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions