viro: Cannot read property 'setJSMaterials' of undefined

Hi,

I keep getting this error in my ios app, not really sure how to resolve it:

Cannot read property 'setJSMaterials' of undefined

Function.createMaterials
    ViroMaterials.js:71:20
<unknown>
    HelloWorldSceneAR.js:68:14
loadModuleImplementation
    require.js:214:4
guardedLoadModule
    require.js:148:11
_require
    require.js:132:2
<unknown>
    App.js:33:21
loadModuleImplementation
    require.js:214:4
guardedLoadModule
    require.js:148:11
_require
    require.js:132:2
<unknown>
    index.js:2

Any help would be appreciated.

Thanks

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 20 (3 by maintainers)

Most upvoted comments

If you still get some build errors after following the guide, make sure you open the xcworkspace instead of xcodeproj as viro react is using coca pods.

Hello @Serdar17 , I have a work around.

This error comes when I use a recent react native version (0.70) especially with expo (sdk >= 45).

To solve my issue, I am using just the starter-kit provided by Viro (here). The expo-viro-starter-kit does not for me, it produces similar errors (VRTText missing).

So I would advice, you use the starter-kit.

Special remarks: 1- You will need to change your /android/build.gradle file to this (see below), because of the recent Maven and jcenter changes in gradle (see blog post here) or else, it might not work:

buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 24
        compileSdkVersion = 30
        targetSdkVersion = 30
        ndkVersion = "20.1.5948944"
    }
    repositories {
        google()
        // mavenCentral()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.2.1")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        exclusiveContent {
            filter {
               includeGroup "com.facebook.react"
            }
            forRepository {
                maven {
                   url "$rootDir/../node_modules/react-native/android"
                }
            }
        }
        mavenCentral()
        mavenLocal()
        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()
        // maven { url 'https://www.jitpack.io' }
        jcenter()
    }
}

2- You can rename your app following this nice tutorial or try the answers in the stackoverflow questions here

There you go, you are good to go. It worked for me. Hope it might help

Hi @faisal3413,

  1. Did you create your project running ‘react-viro init’??
  2. Did you run the script ‘./setup-ide --all’ in your project directory?
  3. If you did 2), what was the output of that script, can you cut and paste that here?
  4. Did you modify the sample code in anyway?

Thanks!

I am using expo just followed the installation guide with expo and go this error