react-native-video的坑

今天本来想用react-native这个库做视频,
首先我执行命令

yarn add react-native-video

然后link

react-native link react-native-video

如果link失败,就自己添加


react-native-video-.png

react-native-video-one.png

然后我运行项目,结果出错了,报错如下:

                                                                     
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > A problem occurred configuring project ':react-native-video'.
      > Could not resolve all dependencies for configuration ':react-native-video:_debugPublishCopy'.
         > Could not find com.android.support:support-annotations:27.0.0.
           Searched in the following locations:
               file:/C:/Users/asus/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-annotation
s/27.0.0/support-annotations-27.0.0.pom
               file:/C:/Users/asus/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-annotation
s/27.0.0/support-annotations-27.0.0.jar
               file:/D:/RNProject/Small/android/sdk-manager/com/android/support/support-annotations/27.0.0/support-annotations-
27.0.0.jar
           Required by:
               Small:react-native-video:unspecified > com.google.android.exoplayer:extension-okhttp:2.7.3
               Small:react-native-video:unspecified > com.google.android.exoplayer:exoplayer:2.7.3 > com.google.android.exoplay
er:exoplayer-core:2.7.3
               Small:react-native-video:unspecified > com.google.android.exoplayer:exoplayer:2.7.3 > com.google.android.exoplay
er:exoplayer-dash:2.7.3
               Small:react-native-video:unspecified > com.google.android.exoplayer:exoplayer:2.7.3 > com.google.android.exoplay
er:exoplayer-hls:2.7.3
               Small:react-native-video:unspecified > com.google.android.exoplayer:exoplayer:2.7.3 > com.google.android.exoplay
er:exoplayer-smoothstreaming:2.7.3
               Small:react-native-video:unspecified > com.google.android.exoplayer:exoplayer:2.7.3 > com.google.android.exoplay
er:exoplayer-ui:2.7.3

这个问题的核心在于这句话:

Could not find com.android.support:support-annotations:27.0.0.

在github上我找到了答案:


react-native-video-five.png

于是我就开始各种百度,谷歌,终于让我找到了解决方案:
这种问题主要是两个方面:
1、Repository问题。需要在android studio上更新版本。
详情见:https://stackoverflow.com/questions/37026322/failed-to-sync-gradle-could-not-find-com-android-supportsupport-annotations23

react-native-video-three.png

2.还有一种情况就是没有加goole 依赖(哈哈,我自创的名字)
在build.grade(不是app里面那个哟)
添加:

maven {
url "https://maven.google.com"
}

如图:
react-native-video-four.png

再次运行!完美执行!搞定!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,492评论 2 45
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,881评论 18 139
  • 总结一下:1、龙湖的售楼部现代,奢华. 性价比高. 售楼妹子最美最帅,主动提供房子资料。2、旭辉,索取资料两次...
    马唐阅读 542评论 0 0
  • 相信有不少朋友看过类似于这样标题的文章吧,《如果你想失去一个朋友,那么请借给他钱吧》,我想同意作者观点的朋友大有人...
    土豆不太熟阅读 547评论 4 7
  • 在回去的车上看完了《你一生的故事》。相比于电影,小说内容更连续,易懂。物理学家刷足了存在感。但小说故事性相比电影来...
    yltianxia阅读 508评论 0 2