React Native java.lang.NoClassDefFoundError:失败的解析:用户界面管理器/用户界面实现提供商;

5cnsuln7  于 2022-11-17  发布在  React
关注(0)|答案(4)|浏览(215)

我在打开我的Android应用程序时遇到。我尝试了以下步骤,但我得到了以下错误。请帮助我。我的Android应用程序构建良好,但当我运行它时,我得到了以下错误。它引用了一个类,这不是我使用的东西。有什么想法?

com.qa.android E/unknown:NativeModuleInitError: Failed to create NativeModule "UIManager"
    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/facebook/react/uimanager/UIImplementationProvider;
        at com.swmansion.reanimated.ReanimatedPackage.createUIManager(ReanimatedPackage.java:73)
        at com.swmansion.reanimated.ReanimatedPackage.getModule(ReanimatedPackage.java:31)
        at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:161)
        at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:149)
        at com.facebook.react.bridge.ModuleHolder.create(ModuleHolder.java:191)
        at com.facebook.react.bridge.ModuleHolder.getModule(ModuleHolder.java:156)
        at com.facebook.react.bridge.NativeModuleRegistry.getModule(NativeModuleRegistry.java:170)
        at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:493)
        at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:469)
        at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:89)
        at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:47)
        at com.facebook.react.ReactInstanceManager.attachRootViewToInstance(ReactInstanceManager.java:1241)
        at com.facebook.react.ReactInstanceManager.setupReactContext(ReactInstanceManager.java:1183)
        at com.facebook.react.ReactInstanceManager.access$1600(ReactInstanceManager.java:135)
        at com.facebook.react.ReactInstanceManager$5$2.run(ReactInstanceManager.java:1137)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
        at android.os.Looper.loop(Looper.java:223)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
        at java.lang.Thread.run(Thread.java:923)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.react.uimanager.UIImplementationProvider" on path: DexPathList[[zip file "/data/app/~~7b9OfUY0mLPaHfZSYMHhqQ==/com.qa.android-4UNR7KbO89A4FSaahSgIvw==/base.apk"],nativeLibraryDirectories=[/data/app/~~7b9OfUY0mLPaHfZSYMHhqQ==/com.qa.android-4UNR7KbO89A4FSaahSgIvw==/lib/arm64, /data/app/~~7b9OfUY0mLPaHfZSYMHhqQ==/com.qa.android-4UNR7KbO89A4FSaahSgIvw==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.swmansion.reanimated.ReanimatedPackage.createUIManager(ReanimatedPackage.java:73) 
        at com.swmansion.reanimated.ReanimatedPackage.getModule(ReanimatedPackage.java:31) 
        at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:161) 
        at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:149) 
        at com.facebook.react.bridge.ModuleHolder.create(ModuleHolder.java:191) 
        at com.facebook.react.bridge.ModuleHolder.getModule(ModuleHolder.java:156) 
        at com.facebook.react.bridge.NativeModuleRegistry.getModule(NativeModuleRegistry.java:170) 
        at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:493) 
        at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:469) 
        at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:89) 
        at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:47) 
        at com.facebook.react.ReactInstanceManager.attachRootViewToInstance(ReactInstanceManager.java:1241) 
        at com.facebook.react.ReactInstanceManager.setupReactContext(ReactInstanceManager.java:1183) 
        at com.facebook.react.ReactInstanceManager.access$1600(ReactInstanceManager.java:135) 
        at com.facebook.react.ReactInstanceManager$5$2.run(ReactInstanceManager.java:1137) 
        at android.os.Handler.handleCallback(Handler.java:938) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27) 
        at android.os.Looper.loop(Looper.java:223) 
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228) 
        at java.lang.Thread.run(Thread.java:923) 
    
    
    --------- beginning of crash
2022-11-06 01:30:47.279 20077-20173/com.qa.android E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
    Process: com.qa.android, PID: 20077
    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/facebook/react/uimanager/UIImplementationProvider;
        at com.swmansion.reanimated.ReanimatedPackage.createUIManager(ReanimatedPackage.java:73)
        at com.swmansion.reanimated.ReanimatedPackage.getModule(ReanimatedPackage.java:31)
        at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:161)
        at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:149)
        at com.facebook.react.bridge.ModuleHolder.create(ModuleHolder.java:191)
        at com.facebook.react.bridge.ModuleHolder.getModule(ModuleHolder.java:156)
        at com.facebook.react.bridge.NativeModuleRegistry.getModule(NativeModuleRegistry.java:170)
        at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:493)
        at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:469)
        at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:89)
        at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:47)
        at com.facebook.react.ReactInstanceManager.attachRootViewToInstance(ReactInstanceManager.java:1241)
        at com.facebook.react.ReactInstanceManager.setupReactContext(ReactInstanceManager.java:1183)
        at com.facebook.react.ReactInstanceManager.access$1600(ReactInstanceManager.java:135)
        at com.facebook.react.ReactInstanceManager$5$2.run(ReactInstanceManager.java:1137)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
        at android.os.Looper.loop(Looper.java:223)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
        at java.lang.Thread.run(Thread.java:923)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.react.uimanager.UIImplementationProvider" on path: DexPathList[[zip file "/data/app/~~7b9OfUY0mLPaHfZSYMHhqQ==/com.qa.android-4UNR7KbO89A4FSaahSgIvw==/base.apk"],nativeLibraryDirectories=[/data/app/~~7b9OfUY0mLPaHfZSYMHhqQ==/com.qa.android-4UNR7KbO89A4FSaahSgIvw==/lib/arm64, /data/app/~~7b9OfUY0mLPaHfZSYMHhqQ==/com.qa.android-4UNR7KbO89A4FSaahSgIvw==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.swmansion.reanimated.ReanimatedPackage.createUIManager(ReanimatedPackage.java:73) 
        at com.swmansion.reanimated.ReanimatedPackage.getModule(ReanimatedPackage.java:31) 
        at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:161) 
        at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:149) 
        at com.facebook.react.bridge.ModuleHolder.create(ModuleHolder.java:191) 
        at com.facebook.react.bridge.ModuleHolder.getModule(ModuleHolder.java:156) 
        at com.facebook.react.bridge.NativeModuleRegistry.getModule(NativeModuleRegistry.java:170) 
        at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:493) 
        at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:469) 
        at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:89) 
        at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:47) 
        at com.facebook.react.ReactInstanceManager.attachRootViewToInstance(ReactInstanceManager.java:1241) 
        at com.facebook.react.ReactInstanceManager.setupReactContext(ReactInstanceManager.java:1183) 
        at com.facebook.react.ReactInstanceManager.access$1600(ReactInstanceManager.java:135) 
        at com.facebook.react.ReactInstanceManager$5$2.run(ReactInstanceManager.java:1137) 
        at android.os.Handler.handleCallback(Handler.java:938) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27) 
        at android.os.Looper.loop(Looper.java:223) 
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228) 
        at java.lang.Thread.run(Thread.java:923) 

我是这样实现的

if (enableHermes) {
        implementation("com.facebook.react:hermes-engine:+") {
            exclude group:'com.facebook.fbjni'
                 }
//        def hermesPath = "../../node_modules/hermes-engine/android/";
//        debugImplementation files(hermesPath + "hermes-debug.aar")
//        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }

我在启动时死机。请帮助我。

68bkxrlz

68bkxrlz1#

这是过去2天的已知问题趋势。
把这个加到你的allprojects里面

def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())

allprojects {
    configurations.all {
        resolutionStrategy {
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
        }
    }
}

我关注了这个评论https://github.com/facebook/react-native/issues/35204#issuecomment-1304281740,现在它工作得很好。

nmpmafwu

nmpmafwu2#

构建在Ammar's original answer之上🙏,
如果有人在Gradle中寻找解决方案(不使用命令行和节点。可能有助于避免某些CI/CD限制)

def REACT_NATIVE_VERSION = {
  def inputFile = new File("$rootDir/../package.json")
  def packageJson = new JsonSlurper().parseText(inputFile.text)

  return packageJson["dependencies"]["react-native"]
}()

allprojects {
    configurations.all {
      resolutionStrategy {
        force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
      }
    }
}

您必须根据文件结构更改package.json路径。
Official issue here

zrfyljdw

zrfyljdw3#

每一个人都面临着这个问题,甚至我也是我通过在app/build.gradle中添加这些代码来解决这个问题

def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim());
                configurations.all {
        resolutionStrategy {
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
    }
}
dkqlctbz

dkqlctbz4#

Facebook已提供解决此问题的说明。不再建议使用之前答案中提到的解决方法。请参阅本文以获取指导。Facebook's solution

相关问题