9

I want to use react-native-video in my project. After installing this package I got this error every time (Only in android). I have added all the additional codes that are given in the documentation.

My react-native version is: 0.66.3

And react-native-video version is: 5.2.0

Is there any way to get rid of this error?

Jim Khan
  • 397
  • 3
  • 13

4 Answers4

29

jCenter does not allow to update package anymore, all other packages should be taken from mavenCentral.

You can add jcenter to android/build.gradle like this:

allprojects {
    repositories {
        .... # rest of your code
        jcenter() {
            content {
                includeModule("com.yqritc", "android-scalablevideoview")
            }
        }
    }
}
Younis Rahman
  • 637
  • 5
  • 13
4

If you don't want to add jcenter to all your project nor use a forked library, you can patch the package on your project with patch-package. For this :

  1. go to node_modules/react-native-video/android/build.gradle and add the below fix to your package
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. run npx patch-package react-native-video to apply the patch to your project
  2. Finish the patch-package setup on your project
  3. rebuild your android project with yarn android
Alex D
  • 41
  • 3
  • The best answer, no need to modify my current source code – AmerllicA Sep 02 '22 at 11:50
  • I would upvote this answer 10 times if I could. I can't even express how much I hate to make modifications to my own code as a workaround for a bug in some random package that I will eventually forget to revert when the package gets an update. You made my day bro! :) – Lukasz Spas Nov 04 '22 at 06:21
3

This issue seems to happen with react-native-video. For those who are having issues with jcenter() being deprecated, heres how to resolve:

  1. replace react-native-video in package.json with "react-native-video": "https://github.com/MatrixFrog/react-native-video#11ca8a6799f932a5f24da85dfe68c696ad13a753"

  2. In android/build.gradle, add maven { url 'https://www.jitpack.io' } in repositories, it should look like:

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

  1. In android/app/build.gradle add implementation 'com.github.MatrixFrog:Android-ScalableVideoView:v1.0.4-jitpack'

  2. delete your package-lock.json and node_modules, and reinstall.

  3. clean/rebuild in android studio.

and voala.

Raziel
  • 1,448
  • 2
  • 17
  • 35
0

react-native-video is currently sourcing from google repository on version 6.0.0.alpha.

Juangui Jordán
  • 6,091
  • 2
  • 35
  • 31