Native module RNVectorIcons tries to override RNVectorIcons
danielaloycedaniel opened this issue · 2 comments
After following all the installation process of React Native Vector Icons on GitHub, i ended up getting this error telling me that:
Native module RNVectorIcons tries to override RNVectorIcons. Check the getPackages() method in MainApplication.java, it might be that module is being created twice. If this was your intention, set canOverrideExsistingModule=true. This error may also be present if the package is present only once in getPackages() but is also automatically added later during build time by autolinking. Try removing the existing entry and rebuild.
My Application.kt looks like this:
package com.project
import android.app.Application
import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
import com.facebook.react.ReactHost
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackage
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.soloader.SoLoader
import com.oblador.vectoricons.VectorIconsPackage;
class MainApplication : Application(), ReactApplication {
override val reactNativeHost: ReactNativeHost =
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> =
PackageList(this).packages.apply {
add(VectorIconsPackage())
// Packages that cannot be autolinked yet can be added manually here, for example:
// add(MyReactNativePackage())
}
override fun getJSMainModuleName(): String = "index"
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
}
override val reactHost: ReactHost
get() = getDefaultReactHost(applicationContext, reactNativeHost)
override fun onCreate() {
super.onCreate()
SoLoader.init(this, false)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
}
}
}
If i try to remove add(VectorIconsPackage())
, i get two errors. The first error looks like this:
ERROR Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'VectorIcons' could not be found. Verify that a module by this name is registered in the native binary.Bridgeless mode: false. TurboModule interop: false. Modules loaded: {"NativeModules":["PlatformConstants","LogBox","Timing","AppState","SourceCode","BlobModule","WebSocketModule","DevSettings","DevToolsSettingsManager","Networking","Appearance","DevLoadingView","HeadlessJsTaskSupport","UIManager","DeviceInfo","ImageLoader","SoundManager","IntentAndroid","DeviceEventManager"],"TurboModules":[],"NotFound":["NativePerformanceCxx","NativePerformanceObserverCxx","RedBox","BugReporting","LinkingManager","VectorIcons"]}, js engine: hermes
LOG Running "Project" with {"rootTag":11}
The second error looks like this:
Invariant Violation: "Project" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: Project
Dependencies:
"dependencies": {
"@react-native-vector-icons/ionicons": "^7.4.0-alpha.16",
"@types/react-native-vector-icons": "^6.4.18",
"react": "18.2.0",
"react-native": "0.74.3",
"react-native-vector-icons": "^10.1.0"
}
@danielaloycedaniel You are mixing and matching the yet to be released multiple package version of RNVI.
I would recommend using the new version if this is a new project, which would mean replacing react-native-vector-icons
with `@react-native-vector-icons/common'.
See the instructions at https://github.com/oblador/react-native-vector-icons/tree/monorepo
@danielaloycedaniel You are mixing and matching the yet to be released multiple package version of RNVI.
I would recommend using the new version if this is a new project, which would mean replacing
react-native-vector-icons
with `@react-native-vector-icons/common'.See the instructions at https://github.com/oblador/react-native-vector-icons/tree/monorepo
Thanks, i added two similar dependecies, i uninstalled "@react-native-vector-icons/ionicons": "^7.4.0-alpha.16" and leave react-native-vector-icons and that fixed an error. Thanks a lot.