Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails with react native 0.65 (android only) #2468

Closed
alexisbronchart opened this issue Aug 26, 2021 · 25 comments
Closed

Build fails with react native 0.65 (android only) #2468

alexisbronchart opened this issue Aug 26, 2021 · 25 comments

Comments

@alexisbronchart
Copy link

Bug

Android build fails when using react-native-video with react native 0.65.

Platform

Which player are you experiencing the problem on:

  • Android ExoPlayer (I guess that's the default?)

Environment info

React native info output:

info Fetching system and libraries information...
System:
    OS: macOS 11.5.2
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    Memory: 33.53 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.4.0 - /var/folders/r4/pdxxhfbj3cqg_0n5th1p2t400000gn/T/yarn--1629982469013-0.5589450802855631/node
    Yarn: 1.22.11 - /var/folders/r4/pdxxhfbj3cqg_0n5th1p2t400000gn/T/yarn--1629982469013-0.5589450802855631/yarn
    npm: 7.18.1 - /usr/local/bin/npm
    Watchman: 2021.08.02.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.2 - /Users/jafar/.rbenv/shims/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.0, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7621141
    Xcode: 13.0/13A5212g - /usr/bin/xcodebuild
  Languages:
    Java: 12.0.2 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2
    react-native: 0.65.1 => 0.65.1
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
✨  Done in 2.86s.

Library version: 5.1.1

Steps To Reproduce

  1. npx react-native init TestRNVideo
  2. yarn install react-native-video
  3. yarn android
$ yarn android
yarn run v1.22.11
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 898 file(s) to forward-jetify. Using 12 workers...
info JS server already running.
* daemon not running; starting now at tcp:5037
* daemon started successfully
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
> Task :app:mergeDebugAssets FAILED
8 actionable tasks: 8 executed

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugAssets'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.yqritc:android-scalablevideoview:1.0.4.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
       - file:/[...]/.m2/repository/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
       - file:/[...]/test/TestRNVideo/node_modules/react-native/android/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
       - file:/[...]/test/TestRNVideo/node_modules/jsc-android/dist/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
       - https://dl.google.com/dl/android/maven2/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
       - https://www.jitpack.io/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
     Required by:
         project :app > project :react-native-video

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 14s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugAssets'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.yqritc:android-scalablevideoview:1.0.4.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
       - file:/[...]/.m2/repository/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
       - file:/[...]/test/TestRNVideo/node_modules/react-native/android/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
       - file:/[...]/test/TestRNVideo/node_modules/jsc-android/dist/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
       - https://dl.google.com/dl/android/maven2/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
       - https://www.jitpack.io/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
     Required by:
         project :app > project :react-native-video

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 14s

    at makeError (/[...]/test/TestRNVideo/node_modules/execa/index.js:174:9)
    at /[...]/test/TestRNVideo/node_modules/execa/index.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runOnAllDevices (/[...]/test/TestRNVideo/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:106:5)
    at async Command.handleAction (/[...]/test/TestRNVideo/node_modules/@react-native-community/cli/build/index.js:186:9)
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected behaviour

  1. It builds without error.
@alexisbronchart alexisbronchart changed the title Not working with react native 0.65 (android only) Build fails with react native 0.65 (android only) Aug 26, 2021
@stephane-r
Copy link

stephane-r commented Aug 27, 2021

PR already open, but not sure if it's the right fix when reading the comments.

#2462

@wouterds
Copy link

wouterds commented Sep 2, 2021

jcenter() was removed in favor of mavenCentral() in 0.65, add it back to allprojects.repositories and it'll magically work again.

@stephane-r
Copy link

stephane-r commented Sep 2, 2021

Nop totaly for some usecase, see #2462 (comment)

@wouterds
Copy link

wouterds commented Sep 2, 2021

Hmm weird, worked for me just adding jcenter back

@wbroek
Copy link

wbroek commented Sep 6, 2021

I would advice to define the package so other dependencies are not fetched/taken from jCenter anymore. Because jCenter does not allow any updates anymore of any package all other packages should be taken from mavenCentral for example.

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

allprojects {
    repositories {
        .... # Keep the rest
        jcenter() {
            content {
                includeModule("com.yqritc", "android-scalablevideoview")
            }
        }
    }
}

Hopefully somebody updates android-scalablevideoview to use another repository

@SGarcia710
Copy link

I would advice to define the package so other dependencies are not fetched/taken from jCenter anymore. Because jCenter does not allow any updates anymore of any package all other packages should be taken from mavenCentral for example.

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

allprojects {
    repositories {
        .... # Keep the rest
        jcenter() {
            content {
                includeModule("com.yqritc", "android-scalablevideoview")
            }
        }
    }
}

Hopefully somebody updates android-scalablevideoview to use another repository

Working now, thank you!

@sebastianpaz
Copy link

Thank you!

@MortezaHeydari97
Copy link

I would advice to define the package so other dependencies are not fetched/taken from jCenter anymore. Because jCenter does not allow any updates anymore of any package all other packages should be taken from mavenCentral for example.

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

allprojects {
    repositories {
        .... # Keep the rest
        jcenter() {
            content {
                includeModule("com.yqritc", "android-scalablevideoview")
            }
        }
    }
}

Hopefully somebody updates android-scalablevideoview to use another repository

It works for me too. So thanks my friend !

@milad755
Copy link

milad755 commented Nov 7, 2021

cd android
./gradlew clean
and than :
`
allprojects {
repositories {
.... # Keep the rest
jcenter() {
content {
includeModule("com.yqritc", "android-scalablevideoview")
}
}
}
}

`

@ahmadyusufcodes
Copy link

I would advice to define the package so other dependencies are not fetched/taken from jCenter anymore. Because jCenter does not allow any updates anymore of any package all other packages should be taken from mavenCentral for example.

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

allprojects {
    repositories {
        .... # Keep the rest
        jcenter() {
            content {
                includeModule("com.yqritc", "android-scalablevideoview")
            }
        }
    }
}

Hopefully somebody updates android-scalablevideoview to use another repository

Worked! Thank you!🤗✌

@Shihaburabbi
Copy link

Shihaburabbi commented Nov 22, 2021

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

jcenter() //add this line

@areebshakeel
Copy link

allprojects {
repositories {
mavenCentral()
mavenLocal()
jcenter()
}

@Divyansh-chaudhary
Copy link

Divyansh-chaudhary commented Dec 21, 2021

Thanks buddy it worked

@GregVes
Copy link

GregVes commented Jan 13, 2022

Adding jcenter() is not a working solution anymore

@jherencia
Copy link

yqritc/Android-ScalableVideoView#52 (comment)

@NensiKasundra
Copy link

Yes, Same Issue.

Execution failed for task ':app:mergeDebugJavaResource'.

Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find com.yqritc:android-scalablevideoview:1.0.4.

jcenter is deprecated. it's not a permanent solution.

It's not available on maven.

https://dl.google.com/dl/android/maven2/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
https://repo.maven.apache.org/maven2/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
https://www.jitpack.io/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
Please Update.

@auseika
Copy link

auseika commented Feb 24, 2022

This needs to be fixed asap. Please update and release.

@Bekaxp
Copy link

Bekaxp commented Feb 24, 2022

If you are like me and cannot wait for a working release. I patched the react-native-video@5.2.0 like this:

  1. Applying the changes which should come with v5.2.1:
    63f12ea

  2. Applying changes from @MatrixFrog:
    Maven Repo after JCenter shutdown yqritc/Android-ScalableVideoView#52 (comment)
    https://www.jitpack.io/#MatrixFrog/Android-ScalableVideoView/v1.0.4-jitpack

For the patch to work what you need to do is:

  • Go to your project's node_modules and find react-native-video
  • Go into android-exoplayer/gradle.build and apply the changes from point 1
  • Go into android/gradle.build and apply changes from point 2
  • Run npx patch-package react-native-video (this will create a patch)

Now it should work until they release a new stable working version, which I also hope will be soon...

Cheers!

@sabeelmuttil
Copy link

sabeelmuttil commented Apr 14, 2022

just change your android/gradle.build this will work fine

allprojects {
    repositories {
        .... # Keep the rest
        jcenter() {
            content {
                includeModule("com.yqritc", "android-scalablevideoview")
            }
        }
    }
}

@rephidimC
Copy link

Hi guys.
I am struggling to raise a build as I keep getting errors...

Script compilation errors:

Line 21: gradlePlugin {
^ Unresolved reference: gradlePlugin

Line 23: create("react") {
^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public inline fun <U : TypeVariable(T), T : Any> PolymorphicDomainObjectContainer<TypeVariable(T)>.create(name: String, type: KClass<TypeVariable(U)>): TypeVariable(U) defined in org.gradle.kotlin.dsl
public inline fun <U : TypeVariable(T), T : Any> PolymorphicDomainObjectContainer<TypeVariable(T)>.create(name: String, type: KClass<TypeVariable(U)>, configuration: Action<in TypeVariable(U)>): TypeVariable(U) defined in org.gradle.kotlin.dsl
public inline fun PolymorphicDomainObjectContainer<in TypeVariable(U)>.create(name: String): TypeVariable(U) defined in org.gradle.kotlin.dsl
public inline fun PolymorphicDomainObjectContainer<in TypeVariable(U)>.create(name: String, noinline configuration: TypeVariable(U).() -> Unit): TypeVariable(U) defined in org.gradle.kotlin.dsl
public fun DependencyHandler.create(group: String, name: String, version: String? = ..., configuration: String? = ..., classifier: String? = ..., ext: String? = ...): ExternalModuleDependency defined in org.gradle.kotlin.dsl
public inline fun ExtensionContainer.create(name: String, vararg constructionArguments: Any): TypeVariable(T) defined in org.gradle.kotlin.dsl
public inline fun ExtensionContainer.create(name: String, type: KClass<TypeVariable(T)>, vararg constructionArguments: Any): TypeVariable(T) defined in org.gradle.kotlin.dsl
public inline fun ExtensionContainer.create(publicType: KClass<TypeVariable(T)>, name: String, instanceType: KClass<out TypeVariable(T)>, vararg constructionArguments: Any): TypeVariable(T) defined in org.gradle.kotlin.dsl
public inline fun ExtensionContainer.create(publicType: TypeOf<TypeVariable(T)>, name: String, instanceType: KClass<out TypeVariable(T)>, vararg constructionArguments: Any): TypeVariable(T) defined in org.gradle.kotlin.dsl
public inline fun TaskContainer.create(vararg options: Pair<String, Any?>): Task defined in org.gradle.kotlin.dsl
public inline fun TaskContainer.create(name: String, vararg arguments: Any): TypeVariable(T) defined in org.gradle.kotlin.dsl
public inline fun TaskContainer.create(name: String, type: KClass<TypeVariable(T)>): TypeVariable(T) defined in org.gradle.kotlin.dsl
public inline fun TaskContainer.create(name: String, type: KClass<TypeVariable(T)>, vararg constructorArgs: Any): TypeVariable(T) defined in org.gradle.kotlin.dsl
public inline fun TaskContainer.create(name: String, type: KClass<TypeVariable(T)>, configuration: Action<in TypeVariable(T)>): TypeVariable(T) defined in org.gradle.kotlin.dsl
public inline fun <S : TypeVariable(T), T : Any> ModelMap<TypeVariable(T)>.create(name: String, type: KClass<TypeVariable(S)>): Unit defined in org.gradle.kotlin.dsl
public inline fun <S : TypeVariable(T), T : Any> ModelMap<TypeVariable(T)>.create(name: String, type: KClass<TypeVariable(S)>, configAction: Action<in TypeVariable(S)>): Unit defined in org.gradle.kotlin.dsl
public inline fun BinaryTasksCollection.create(name: String, type: KClass<TypeVariable(T)>, config: Action<in TypeVariable(T)>): Unit defined in org.gradle.kotlin.dsl

Line 24: id = "com.facebook.react"
^ Function invocation 'id(...)' expected

Line 24: id = "com.facebook.react"
^ No value passed for parameter 'p0'

Line 24: id = "com.facebook.react"
^ Variable expected

Line 24: id = "com.facebook.react"
^ Type mismatch: inferred type is String but PluginDependencySpec! was expected

Line 25: implementationClass = "com.facebook.react.ReactPlugin"
^ Unresolved reference: implementationClass

Line 33: implementation(gradleApi())
^ Unresolved reference: implementation

Line 34: implementation("com.android.tools.build:gradle:7.1.0")
^ Unresolved reference: implementation

Line 35: implementation("com.google.code.gson:gson:2.8.9")
^ Unresolved reference: implementation

Line 36: implementation("com.google.guava:guava:31.0.1-jre")
^ Unresolved reference: implementation

Line 37: implementation("com.squareup:javapoet:1.13.0")
^ Unresolved reference: implementation

Line 39: testImplementation("junit:junit:4.13.2")
^ Unresolved reference: testImplementation

Line 41: testRuntimeOnly(
^ Unresolved reference: testRuntimeOnly

Line 48: java {
^ Expression 'java' cannot be invoked as a function. The function 'invoke()' is not found

Line 48: java {
^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public val PluginDependenciesSpec.java: PluginDependencySpec defined in org.gradle.kotlin.dsl

Line 49: sourceCompatibility = JavaVersion.VERSION_18
^ Unresolved reference: sourceCompatibility

Line 50: targetCompatibility = JavaVersion.VERSION_18
^ Unresolved reference: targetCompatibility

18 errors

Please help

@yashkumarsharma
Copy link

The following patch worked for me!

diff --git a/node_modules/react-native-video/android-exoplayer/build.gradle b/node_modules/react-native-video/android-exoplayer/build.gradle
index d005a58..04133dd 100644
--- a/node_modules/react-native-video/android-exoplayer/build.gradle
+++ b/node_modules/react-native-video/android-exoplayer/build.gradle
@@ -28,7 +28,7 @@ android {
 
 dependencies {
     implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
-    implementation('com.google.android.exoplayer:exoplayer:2.13.2') {
+    implementation('com.google.android.exoplayer:exoplayer:2.13.3') {
         exclude group: 'com.android.support'
     }
 
@@ -37,9 +37,15 @@ dependencies {
     implementation "androidx.core:core:1.1.0"
     implementation "androidx.media:media:1.1.0"
 
-    implementation('com.google.android.exoplayer:extension-okhttp:2.13.2') {
+    implementation('com.google.android.exoplayer:extension-okhttp:2.13.3') {
         exclude group: 'com.squareup.okhttp3', module: 'okhttp'
     }
     implementation 'com.squareup.okhttp3:okhttp:${OKHTTP_VERSION}'
 
 }
+
+allprojects {
+    repositories {
+        maven { url 'https://www.jitpack.io' }
+    }
+}
\ No newline at end of file
diff --git a/node_modules/react-native-video/android/build.gradle b/node_modules/react-native-video/android/build.gradle
index 2fb8dfd..b45c0e5 100644
--- a/node_modules/react-native-video/android/build.gradle
+++ b/node_modules/react-native-video/android/build.gradle
@@ -22,5 +22,11 @@ android {
 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'
+}
+
+allprojects {
+    repositories {
+        maven { url 'https://www.jitpack.io' }
+    }
 }

@hueniverse
Copy link
Contributor

Please use the examples and https://github.com/react-native-video/react-native-video-test as reference. Both build without issues.

@arsimr16
Copy link

I was able to use react-native-video 5.2.0 without using jcenter by switching to the Android ExoPlayer. android-scalablevideoview is only used by the Android MediaPlayer which is being removed in version 6.x of react-native-video anyway.

  1. Add the following lines to settings.gradle to use the ExoPlayer instead of the MediaPlayer:
include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer')
  1. Once I switched to the ExoPlayer, I got errors from react-native-video/android-exoplayer/build.gradle about com.google.android.exoplayer:exoplayer:2.13.2 and com.google.android.exoplayer:extension-okhttp:2.13.2 not being available. I made a patch to change both versions to 2.13.3, and my app built successfully after that.

@jrhager84
Copy link

I was able to use react-native-video 5.2.0 without using jcenter by switching to the Android ExoPlayer. android-scalablevideoview is only used by the Android MediaPlayer which is being removed in version 6.x of react-native-video anyway.

  1. Add the following lines to settings.gradle to use the ExoPlayer instead of the MediaPlayer:
include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer')
  1. Once I switched to the ExoPlayer, I got errors from react-native-video/android-exoplayer/build.gradle about com.google.android.exoplayer:exoplayer:2.13.2 and com.google.android.exoplayer:extension-okhttp:2.13.2 not being available. I made a patch to change both versions to 2.13.3, and my app built successfully after that.

After running a gradle clean after upgrading Flipper, I get 'no variant found for :react-native-video' and it won't build. Usually the edits you did were enough for me to get it to build, but I can't get react-native-video back into the gradle files. Any ideas?

@freeboub
Copy link
Collaborator

Please use release 5.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests