TypeError: null 不是对象(正在评估 'TrackPlayer.RATING_HEART') && Module AppRegistry 不是已注册的可调用模块

Mic*_*ger 2 android reactjs react-native react-native-track-player

在过去 1.5 天左右的时间里,我试图让 React-native-track-player 工作,但我就是无法实现它。无论我尝试什么,我总是会遇到相同的错误块:

\n
ERROR  TypeError: null is not an object (evaluating \'TrackPlayer.RATING_HEART\')\nERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect. \n      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.\n
Run Code Online (Sandbox Code Playgroud)\n

我使用react-native expo和 “正常” react-native(根据react-native docu)设置它。对于我尝试过的所有变体:JSTS

\n
    \n
  • 删除/重新安装节点模块
  • \n
  • npm cache verify(如此所述),react-native start --reset-cache(来自此处)以及其他一些缓存重置/删除内容。
  • \n
  • 我从他们的 GitHub 存储库复制了该示例
  • \n
  • 我更新和/或重新安装了几乎每个库(包括node
  • \n
\n

所有这些努力都以完全相同的错误告终。

\n

所以,我真的不知道该怎么办了。一般来说,我是反应原生和应用程序开发的初学者。所以说实话,我犯的错误很可能是超级愚蠢/简单的。但我就是找不到它。如果有任何建议,我将非常感激。

\n

编辑-依赖错误:\xc2\xa0在此输入图像描述

\n

编辑2:解决方案-react-native删除了我所有问题的根源,请检查下面我的答案以了解详细信息jcenterv0.64 v0.65

\n

Mic*_*ger 6

编辑:jcenter()肯定会被删除。检查GitHub 线程,了解有关如何继续使用react-native-track-player.

好吧,虽然从他们的存储库克隆示例有效(感谢@AngwarGul),但我仍然想弄清楚为什么会这样。事实证明,错误的根本原因在于文件中build.gradle

我一直在使用react-native@0.65.1但不知道 from v0.64to已从react-native中v0.65 jcenter 删除。因此,运行时react-native run-android无法构建应用程序,因为它找不到 jcenter。所以,我可能早就意识到了这一点,但我一直在寻找除了那里之外的任何地方。

TL;DR:添加jcenter()到 build.gradle 文件为我解决了整个问题(见下图)。因此,如果其他人犯了同样的愚蠢错误,这是您的解决方案;)

在此输入图像描述