在Android中找不到com.yqritc:android-scalablevideoview:1.0.4 react-native-video。

9
我想在我的项目中使用react-native-video。在安装此软件包后,每次(仅在Android上)都会出现此错误。我已经添加了文档中提供的所有其他代码。
我的react-native版本是:0.66.3 react-native-video版本是:5.2.0 有没有什么方法可以摆脱这个错误?
4个回答

29

jCenter已不再允许更新软件包,所有其他软件包应从mavenCentral获取。

您可以像这样将jcenter添加到android/build.gradle中:

allprojects {
    repositories {
        .... # rest of your code
        jcenter() {
            content {
                includeModule("com.yqritc", "android-scalablevideoview")
            }
        }
    }
}


4

如果您不想将jcenter添加到所有项目中,也不想使用分支库,您可以使用patch-package在项目中修补包。

  1. 前往 node_modules/react-native-video/android/build.gradle,并将以下修复内容添加到您的包中。
diff --git a/node_modules/react-native-video/android/build.gradle b/node_modules/react-native-video/android/build.gradle
index 2fb8dfd..eb7ecdf 100644
--- a/node_modules/react-native-video/android/build.gradle
+++ b/node_modules/react-native-video/android/build.gradle
@@ -19,8 +19,12 @@ android {
     }
 }
 
+repositories {
+    maven { url 'https://www.jitpack.io' }
+}
+
 dependencies {
     //noinspection GradleDynamicVersion
     implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
-    implementation 'com.yqritc:android-scalablevideoview:1.0.4'
+    implementation 'com.github.MatrixFrog:android-scalablevideoview:v1.0.4-jitpack'
 }

  1. 运行 npx patch-package react-native-video 将补丁应用到您的项目中
  2. 完成您项目中的 patch-package 设置
  3. 使用 yarn android 重新构建您的安卓项目

最佳答案,无需修改我的当前源代码。 - AmerllicA
如果可以的话,我会给这个答案点赞十次。我甚至无法表达我有多讨厌修改自己的代码来解决某个随机包中的错误,而当该包得到更新时,我最终会忘记还原它。你让我今天过得很愉快,兄弟! :) - Lukasz Spas

3

这个问题似乎是与react-native-video有关的。对于那些遇到jcenter()被弃用的问题,以下是解决方法:

  1. package.json中用"react-native-video": "https://github.com/MatrixFrog/react-native-video#11ca8a6799f932a5f24da85dfe68c696ad13a753"替换react-native-video

  2. android/build.gradle中的repositories中添加maven { url 'https://www.jitpack.io' },其应如下所示:

allprojects {
        repositories {
            ...
            maven { url 'https://www.jitpack.io' }
        }
    }

  1. android/app/build.gradle文件中添加implementation 'com.github.MatrixFrog:Android-ScalableVideoView:v1.0.4-jitpack'

  2. 删除package-lock.jsonnode_modules文件夹,然后重新安装。

  3. 在Android Studio中进行清理/重建操作。

完成。


0

react-native-video 目前从版本 6.0.0.alpha 的 google 存储库中获取。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接