Open diessetechnology opened 1 month ago
Thank you for your issue report. Please note that the following information is missing or incomplete:
Please update your issue with this information to help us address it more effectively.
Note: issues without complete information have a lower priority
which react native version do you use ?
just for information, your comment is right: The syntax you provided, which uses the enhanced switch expression with the -> arrow notation and returning a value, is supported starting from Java 12 under the preview feature, and it became a standard feature in Java 14.
Here’s a summary of the relevant Java versions:
Java 12: Introduced the new switch expression as a preview feature. Java 13: Continued the preview of this feature with some refinements. Java 14: The switch expression became a standard feature. So, starting from Java 14, this syntax is fully supported and no longer requires enabling preview features.
React native is version 0.71.7. And so, it seems to be a error related directly to ExoPlayer. But it affects react-native-video in the matter that i can't compile app for android. Did i have to open a issue to google/ExoPlayer repo? Because is a thing that is abnormal to happen with JDK 17...and now i'm questioning myself if is a error that happen in non-react native apps that use ExoPlayer...
Like i said, no issue about this i've found online, nor on react-native-video nor in Exoplayer repos. And neither in StackOverflow like sites...So i deduce that is a new error of some update in react-native-video or ExoPlayer
This fixed for me:
Updated(In ReactExoplayerView):
float speed = switch (which) {
case 0 -> 0.5f;
case 2 -> 1.5f;
case 3 -> 2.0f;
default -> 1.0f;
};
TO
switch (which) {
case 0:
speed = 0.5f;
break;
case 2:
speed = 1.5f;
break;
case 3:
speed = 2.0f;
break;
default:
speed = 1.0f;
break;
}
Then did:
npx patch-package react-native-video
Is solved. Thank you very much for help @Ajmal0197
I reopen this because you can track the fix for package. I can confirm that the solution is that of the user i thanked. Thanks again to everyone.
I hade same issue, i'm not a fan of patch, the workaround that work for me was explicit define java version on android/build.gradle
I add this peace of code
subprojects {
afterEvaluate { project ->
if (project.hasProperty("android")) {
project.android.compileOptions {
sourceCompatibility JavaVersion.VERSION_14
targetCompatibility JavaVersion.VERSION_14
}
}
}
}
I hade same issue, i'm not a fan of patch, the workaround that work for me was explicit define java version on
android/build.gradle
I add this peace of code
subprojects { afterEvaluate { project -> if (project.hasProperty("android")) { project.android.compileOptions { sourceCompatibility JavaVersion.VERSION_14 targetCompatibility JavaVersion.VERSION_14 } } } }
This is a better solution.
Version
6.7.0
What platforms are you having the problem on?
Android
System Version
Android
On what device are you experiencing the issue?
Real device
Architecture
New architecture with interop layer
What happened?
A strange bug caused by a "missing feature of java" cause this :react-native-video:compileDebugJavaWithJavac error: /exoplayer/ReactExoplayerView.java:522: error: switch expressions are not supported in -source 11 and tell me to: (use -source 14 or higher to enable switch rules)
I use Azul Zulu JDK 17 on a iMac. So it's really strange that is complaining about a source 11 error (assuming is intending Java 11)
java -version
openjdk version "17.0.11" 2024-04-16 LTS OpenJDK Runtime Environment Zulu17.50+19-CA (build 17.0.11+9-LTS) OpenJDK 64-Bit Server VM Zulu17.50+19-CA (build 17.0.11+9-LTS, mixed mode, sharing)
No bug has been reported nor in react-native-video nor in ExoPlayer repo
Reproduction Link
repository link
Reproduction
Step to reproduce this bug are: Use react-native-video Run react-native run-android, with Azul Zulu JDK 17