viro: RN 0.61.4 crash - No such method putMap

Environment

Please provide the following information about your environment:

  1. Development OS: Mac
  2. Device OS & Version: Android - any version
  3. Version: ViroReact version and React Native version: RN 0.61.4, react-viro 2.17.0
  4. Device(s): Any android device

Description

This looks like a bug related to an internal change with maps from RN and also related to https://github.com/viromedia/viro/issues/756

Viro just fails to open under RN 0.61.4, but works fine on 0.60

Crash logs:

java.lang.NoSuchMethodError No interface method putMap(Ljava/lang/String;Lcom/facebook/react/bridge/WritableMap;)V in class Lcom/facebook/react/bridge/WritableMap; or its super classes (declaration of 'com.facebook.react.bridge.WritableMap' appears in base.apk) 
    VRTScene.java:229 com.viromedia.bridge.component.node.VRTScene.notifyPlatformInformation
    VRTScene.java:219 com.viromedia.bridge.component.node.VRTScene.setPlatformInformation
    VRT3DSceneNavigator.java:235 com.viromedia.bridge.component.VRT3DSceneNavigator.addView
    ViewGroupManager.java:35 com.facebook.react.uimanager.ViewGroupManager.addView
    NativeViewHierarchyManager.java:512 com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren
    UIViewOperationQueue.java:205 com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute
    UIViewOperationQueue.java:779 com.facebook.react.uimanager.UIViewOperationQueue$1.run
    UIViewOperationQueue.java:888 com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches
    UIViewOperationQueue.java:42 com.facebook.react.uimanager.UIViewOperationQueue.access$2200
    UIViewOperationQueue.java:948 com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded
    GuardedFrameCallback.java:28 com.facebook.react.uimanager.GuardedFrameCallback.doFrame
    ReactChoreographer.java:174 com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame
    ChoreographerCompat.java:84 com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame
    Choreographer.java:984 android.view.Choreographer$CallbackRecord.run
    Choreographer.java:764 android.view.Choreographer.doCallbacks
    Choreographer.java:696 android.view.Choreographer.doFrame
    Choreographer.java:965 android.view.Choreographer$FrameDisplayEventReceiver.run
    Handler.java:873 android.os.Handler.handleCallback
    Handler.java:99 android.os.Handler.dispatchMessage
    Looper.java:214 android.os.Looper.loop
    ActivityThread.java:7073 android.app.ActivityThread.main
    Method.java:-2 java.lang.reflect.Method.invoke
    RuntimeInit.java:493 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run
    ZygoteInit.java:965 com.android.internal.os.ZygoteInit.main

Reproducible Demo

Something similar to this

const Viewer360 = (props) => 
(
  <ViroScene>
    <ViroNode>
      <Viro360Image
        source={{uri: this.props.uri}}
        ref={(c => this._component = c)}
      />
    </ViroNode>

  </ViroScene>
)



<ViroVRSceneNavigator
  vrModeEnabled={false}
  initialScene={{
    scene: Viewer360,
    passProps: {uri: someUri}
  }}
/>

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 63 (8 by maintainers)

Most upvoted comments

Well, there is not much to sketch. It’s just very much the same installation steps as the regular react-viro npm package. Except that you would simply use @citychallenge/react-viro instead of the regular one everywhere it is referenced: https://docs.viromedia.com/docs/integrating-with-react-native-projects

Edit: Just fyi, we are talking about a npm package here, you don’t have to clone anything. Just npm install --save @citychallenge/react-viro (https://www.npmjs.com/package/@citychallenge/react-viro)

This is what I did, but as said above, this only fixes it for Android, and not for iOS (although I haven’t had issues with iOS yet), so use it carefully.

  • Download the repo from https://github.com/viromedia/viro
  • Edit the packages.json under the folder /test with the right RN version you need
  • Edit build.gradle to use the right com.facebook.react:react-native version ( I think this is not needed)
  • run ./prepare_release.sh and copy the output from android/react-viro to somewhere in your own project
  • Lastly, copy react_viro-release.aar (the one you just built) into node_modules/react-viro/android/react-viro. You will need to do this every time your node module’s folder overwrites react-viro

Again, I have no idea why would the viro team include the aar file like that in the npm package instead of just providing the source code and letting it build with RN like above. A simple change to do that would save us from this this headache each time RN is updated.

The fix to support RN 0.6x.x is actually rather easy, and my team also needed to run on 0.6x.x. So we have deployed a npm package that supports this version. You can use this in the meantime until we get around to push this fix upstream when we find the time. You still have to manually link pods/android project as you are used to with the official version.

https://www.npmjs.com/package/@citychallenge/react-viro

Does any one know if they’re working on a newer version that supports RN 0.6x.x ? And if so, is there a estimated release date?

@hokaiyipFS Also is this compatible with react-navigation? I mean the ViroSceneARNavigator is it compatible with react-navigation should react-navigation wrap ViroSceneARNavigator or ViroSceneARNavigator should wrap react-navigation navigator?

I think you need to use both, as I am also using both. in normal navigation, you can use your navigation, however, with AR, you will need to use ViroSceneARNavigator to perform navigation

@hokaiyipFS Never mind I found the problem, for anyone that could have it in future I was missing the line in application node in AndroidManifest.xml:

<meta-data android:name="com.google.ar.core" android:value="optional" />

This was mentioned below page, but I could not see line that should be added I had to insepect element on the documentation page to see the line it was hidden:

https://docs.viromedia.com/docs/integrating-existing-projects-android#for-ar

@rgouzal hm. i am running out of ideas. maybe try

  1. react native camera to see if your app can invoke the camera view 1st?
  2. https://github.com/viromedia/viro/tree/master/code-samples <-- try to use exactly the same code?
  3. find anything useful from logcat?

I have used viro-react for more than 1 year. initially with react native 0.59.9, now upgrade to 0.63.2 it just takes a bit of debugging and eventually it will work.

@Hless (or @ anybody really…)

If you find the time and the patience, could you sketch real quick how to add @citychallenge/react-viro to an existing RN 61.x project?

I’m struggling with the ./setup-ide.sh --ios step (assuming that it is needed). It seems to be messing up the Pods.

Much obliged!

Never mind… I see they are built straight from the directory in node_modules.