diff --git a/android/build.gradle b/android/build.gradle index 7920bf6584..5492c667f8 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -5,6 +5,21 @@ apply plugin: 'kotlin-android' buildscript { def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['RNVideo_kotlinVersion'] + def requiredKotlinVersion = project.properties['RNVideo_kotlinVersion'] + + def isVersionAtLeast = { version, requiredVersion -> + def (v1, v2) = [version, requiredVersion].collect { it.tokenize('.')*.toInteger() } + for (int i = 0; i < Math.max(v1.size(), v2.size()); i++) { + int val1 = i < v1.size() ? v1[i] : 0 + int val2 = i < v2.size() ? v2[i] : 0 + if (val1 < val2) { + return false + } else if (val1 > val2) { + return true + } + } + return true + } repositories { mavenCentral() @@ -13,9 +28,17 @@ buildscript { dependencies { classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") } + + ext { + if (!isVersionAtLeast(kotlin_version, requiredKotlinVersion)) { + throw new GradleException("Kotlin version mismatch: Project is using Kotlin version $kotlin_version, but it must be at least $requiredKotlinVersion. Please update the Kotlin version.") + } else { + println("Kotlin version is correct: $kotlin_version") + } + } } -// This looks funny but it's necessary to keep backwards compatibility (: +// This looks funny but it's necessary to keep backwards compatibility (: def safeExtGet(prop) { return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : rootProject.ext.has("RNVideo_" + prop) ? @@ -184,7 +207,6 @@ repositories { } def media3_version = safeExtGet('media3Version') -def kotlin_version = safeExtGet('kotlinVersion') def androidxCore_version = safeExtGet('androidxCoreVersion') def androidxActivity_version = safeExtGet('androidxActivityVersion') @@ -239,7 +261,7 @@ dependencies { implementation "androidx.media3:media3-exoplayer-rtsp:$media3_version" } } - + // For ad insertion using the Interactive Media Ads SDK with ExoPlayer if (ExoplayerDependencies["useExoplayerIMA"]) { if (media3_buildFromSource) { @@ -280,5 +302,4 @@ dependencies { // Common functionality used across multiple media libraries implementation "androidx.media3:media3-common:$media3_version" } - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" -} +} \ No newline at end of file diff --git a/android/gradle.properties b/android/gradle.properties index d4b231664b..46daceb29b 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,4 +1,4 @@ -RNVideo_kotlinVersion=1.7.0 +RNVideo_kotlinVersion=1.8.0 RNVideo_minSdkVersion=23 RNVideo_targetSdkVersion=34 RNVideo_compileSdkVersion=34 diff --git a/android/src/main/java/com/brentvatne/exoplayer/FullScreenPlayerView.kt b/android/src/main/java/com/brentvatne/exoplayer/FullScreenPlayerView.kt index b66c1e88f4..00f9397524 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/FullScreenPlayerView.kt +++ b/android/src/main/java/com/brentvatne/exoplayer/FullScreenPlayerView.kt @@ -91,13 +91,12 @@ class FullScreenPlayerView( parent = null } - private fun getFullscreenIconResource(isFullscreen: Boolean): Int { - return if (isFullscreen) { + private fun getFullscreenIconResource(isFullscreen: Boolean): Int = + if (isFullscreen) { androidx.media3.ui.R.drawable.exo_icon_fullscreen_exit } else { androidx.media3.ui.R.drawable.exo_icon_fullscreen_enter } - } private fun updateFullscreenButton(playerControlView: LegacyPlayerControlView, isFullscreen: Boolean) { val imageButton = playerControlView.findViewById(com.brentvatne.react.R.id.exo_fullscreen) diff --git a/docs/pages/installation.md b/docs/pages/installation.md index e09aa97294..26e1207c47 100644 --- a/docs/pages/installation.md +++ b/docs/pages/installation.md @@ -57,12 +57,14 @@ $RNVideoUseGoogleIMA=true ## Android -From version >= 6.0.0, your application needs to have kotlin version >= 1.7.0 +From version >= 6.0.0, your application needs to have kotlin version >= 1.8.0 ```: buildscript { ... - ext.kotlinVersion = '1.7.0' + ext.kotlinVersion = '1.8.0', + ext.compileSdkVersion = 34 + ext.targetSdkVersion = 34 ... } ```