react-native-video的一个问题,希望大佬指导一下。多谢!



  • react-native的项目要使用react-native-video来实现视频播放功能,ios下没有问题,安卓下该组件报错。报错信息如下:
    TypeError: TypeError: null is not an object (evaluating 'RCTVideoInstance.Constants')

    This error is located at:
    in Video (at Information.js:142)
    in RCTView (at View.js:45)
    in View (at createAnimatedComponent.js:151)
    in AnimatedComponent (at TouchableOpacity.js:282)
    in TouchableOpacity (at Information.js:139)
    in RCTView (at View.js:45)
    in View (at Information.js:138)
    in VideoScreen (at SceneView.js:9)
    in SceneView (at StackViewLayout.tsx:899)
    in RCTView (at View.js:45)
    in View (at StackViewLayout.tsx:898)
    in RCTView (at View.js:45)
    in View (at StackViewLayout.tsx:897)
    in RCTView (at View.js:45)
    in View (at createAnimatedComponent.js:151)
    in AnimatedComponent (at StackViewCard.tsx:106)
    in RCTView (at View.js:45)
    in View (at createAnimatedComponent.js:151)
    in AnimatedComponent (at screens.native.js:71)
    in Screen (at StackViewCard.tsx:93)
    in Card (at createPointerEventsContainer.tsx:95)
    in Container (at StackViewLayout.tsx:985)
    in RCTView (at View.js:45)
    in View (at screens.native.js:101)
    in ScreenContainer (at StackViewLayout.tsx:394)
    in RCTView (at View.js:45)
    in View (at createAnimatedComponent.js:151)
    in AnimatedComponent (at StackViewLayout.tsx:384)
    in PanGestureHandler (at StackViewLayout.tsx:377)
    in StackViewLayout (at withOrientation.js:30)
    in withOrientation (at StackView.tsx:104)
    in RCTView (at View.js:45)
    in View (at Transitioner.tsx:267)
    in Transitioner (at StackView.tsx:41)
    in StackView (at createNavigator.js:80)
    in Navigator (at createKeyboardAwareNavigator.js:12)
    in KeyboardAwareNavigator (at SceneView.js:9)
    in SceneView (at createTabNavigator.js:39)
    in RCTView (at View.js:45)
    in View (at ResourceSavingScene.js:37)
    in RCTView (at View.js:45)
    in View (at ResourceSavingScene.js:26)
    in ResourceSavingScene (at createBottomTabNavigator.js:120)
    in RCTView (at View.js:45)
    in View (at screens.native.js:101)
    in ScreenContainer (at createBottomTabNavigator.js:110)
    in RCTView (at View.js:45)
    in View (at createBottomTabNavigator.js:109)
    in TabNavigationView (at createTabNavigator.js:197)
    in NavigationView (at createNavigator.js:80)
    in Navigator (at SceneView.js:9)
    in SceneView (at SwitchView.js:12)
    in SwitchView (at createNavigator.js:80)
    in Navigator (at createAppContainer.js:430)
    in NavigationContainer (at Launch.js:11)
    in Provider (at Launch.js:10)
    in Launch (at App.js:8)
    in App (at renderApplication.js:35)
    in RCTView (at View.js:45)
    in View (at AppContainer.js:98)
    in RCTView (at View.js:45)
    in View (at react-native-root-siblings/index.js:32)
    in RootSiblingsWrapper (at AppContainer.js:112)
    in RCTView (at View.js:45)
    in View (at AppContainer.js:115)
    in AppContainer (at renderApplication.js:34)

    This error is located at:
    in NavigationContainer (at Launch.js:11)
    in Provider (at Launch.js:10)
    in Launch (at App.js:8)
    in App (at renderApplication.js:35)
    in RCTView (at View.js:45)
    in View (at AppContainer.js:98)
    in RCTView (at View.js:45)
    in View (at react-native-root-siblings/index.js:32)
    in RootSiblingsWrapper (at AppContainer.js:112)
    in RCTView (at View.js:45)
    in View (at AppContainer.js:115)
    in AppContainer (at renderApplication.js:34)
    render
    normalizeColor.js:217:14
    finishClassComponent
    PlanBonusHistory.js:52:15
    updateClassComponent

    performUnitOfWork
    ToastContainer.js:217:13
    workLoop
    ToastContainer.js:257:28
    renderRoot

    performWorkOnRoot
    ExchangeDetails.js:33:4
    performWork

    performSyncWork
    RadioView.js:58:14
    batchedUpdates$1
    ExchangeDetails.js:137:33
    batchedUpdates
    ReInvest.js:143:15
    _receiveRootNodeIDEvent
    QuantitativeTradingMarket.js:11
    receiveTouches

    __callFunction
    market_selected.png:1
    <unknown>
    react-native-implementation.js:264:16
    __guard
    settings_selected.png:1:105
    callFunctionReturnFlushedQueue

    callFunctionReturnFlushedQueue
    [native code]
    0_1571315005349_d0f80ce2-7770-4b2b-81a9-793bd87d2037-image.png
    对应代码如下
    0_1571315047674_5eaa4ff8-112a-45cd-b7ef-c32d3ef6cfa4-image.png
    求大佬指导。多谢!



  • 没有正确link或link后没有编译(run-android)或编译没有通过



  • This post is deleted!


  • @晴明 您好。run-android执行了,怎么看是否编译成功啊?



  • 没有报错就是编译成功



  • @晴明 嗯嗯。那您说的第三种可能性,没有编译通过,是不是也没问题啊? 是我link有问题吗?给您贴一下我link的提示。0_1571368028635_5ba0502f-c7a9-4038-9702-a4163487df26-image.png



  • 看提示是成功了,但是link的情况很复杂,未必命令说成功就是成功了
    RN什么版本?0.60以上不应该执行link,0.60以下必须执行link。是创建时就0.60还是升级到0.60?升级过程中gradle的各种配置是否正确添加?
    是纯RN还是嵌入原生项目?嵌入原生项目又必须手动加入package,等等



  • @晴明 嗯,是0.59版本的RN,我也都不懂是纯RN还是嵌入原生项目。刚开始做RN开发,是写RN的代码生成ios和安卓版本的工程并打包。是嵌入吗?如果是的请问一下怎么手动加入package啊?



  • react-native init生成的项目,结构无更改,即是纯RN项目
    先有原生项目,后加入RN模块,即为嵌入原生项目。各家嵌入原生的方案不同,得让你们原生开发人员自己琢磨。



  • @晴明 好的 我们这应该是纯RN项目。我去找我们安卓人员帮我看下这个问题。谢谢您的帮忙解答啊!



  • 嵌入原生项目才让原生开发人员去看啊,纯RN项目就只用对着文档自己检查就完了



  • @晴明 嗯嗯 我照着react-native-video的官方配置,改了android文件夹下的build.gradle 突然就好使了 很懵逼 哈哈 不过还是很开心 谢谢您的指导啊!



  • @晴明 对了 大佬 还想请教您一个问题,react-native-video能够播放音频吗?



  • 这样一个问题你自己试一下能要多久?



  • 哈哈 第一次试没成功 原来是我样式写错了 是可以的


Log in to reply