react-native-video的坑
2018-08-11 本文已影响1101人
安卓小白之小楼又东风
今天本来想用react-native这个库做视频,
首先我执行命令
yarn add react-native-video
然后link
react-native link react-native-video
如果link失败,就自己添加
![](https://img.haomeiwen.com/i11480012/ae894671f9f07ebc.png)
![](https://img.haomeiwen.com/i11480012/4c547ba41f6cb8a2.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上我找到了答案:
![](https://img.haomeiwen.com/i11480012/cc4b85b00486ae84.png)
于是我就开始各种百度,谷歌,终于让我找到了解决方案:
这种问题主要是两个方面:
1、Repository问题。需要在android studio上更新版本。
详情见:https://stackoverflow.com/questions/37026322/failed-to-sync-gradle-could-not-find-com-android-supportsupport-annotations23
![](https://img.haomeiwen.com/i11480012/69ae438ee151fa46.png)
2.还有一种情况就是没有加goole 依赖(哈哈,我自创的名字)
在build.grade(不是app里面那个哟)
添加:
maven {
url "https://maven.google.com"
}
如图:
![](https://img.haomeiwen.com/i11480012/8964968a01527483.png)
再次运行!完美执行!搞定!