今天本來想用react-native這個(gè)庫做視頻,
首先我執(zhí)行命令
yarn add react-native-video
然后link
react-native link react-native-video
如果link失敗,就自己添加

react-native-video-.png

react-native-video-one.png
然后我運(yùn)行項(xiàng)目,結(jié)果出錯(cuò)了,報(bào)錯(cuò)如下:
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
這個(gè)問題的核心在于這句話:
Could not find com.android.support:support-annotations:27.0.0.
在github上我找到了答案:

react-native-video-five.png
于是我就開始各種百度,谷歌,終于讓我找到了解決方案:
這種問題主要是兩個(gè)方面:
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 依賴(哈哈,我自創(chuàng)的名字)
在build.grade(不是app里面那個(gè)喲)
添加:
maven {
url "https://maven.google.com"
}
如圖:
react-native-video-four.png
再次運(yùn)行!完美執(zhí)行!搞定!