feat(android): add error handling for Kotlin version (#4018)
* feat(android): add error handling for Kotlin version mismatch * fix: lint error * refactor: use variables from gradle file * chore: downgrade required Kotlin version * refactor: check Kotlin version * refactor: kotlin variables in build.gradle * refactor: kotlin variables in build.gradle * chore(doc): update document * chore: add dependency to build.gradle for a specific version of react-native * fix: remove additional dependency
This commit is contained in:
parent
adbd06e2df
commit
6189080c9a
@ -5,6 +5,21 @@ apply plugin: 'kotlin-android'
|
|||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['RNVideo_kotlinVersion']
|
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 {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -13,9 +28,17 @@ buildscript {
|
|||||||
dependencies {
|
dependencies {
|
||||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
|
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) {
|
def safeExtGet(prop) {
|
||||||
return rootProject.ext.has(prop) ?
|
return rootProject.ext.has(prop) ?
|
||||||
rootProject.ext.get(prop) : rootProject.ext.has("RNVideo_" + prop) ?
|
rootProject.ext.get(prop) : rootProject.ext.has("RNVideo_" + prop) ?
|
||||||
@ -184,7 +207,6 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def media3_version = safeExtGet('media3Version')
|
def media3_version = safeExtGet('media3Version')
|
||||||
def kotlin_version = safeExtGet('kotlinVersion')
|
|
||||||
def androidxCore_version = safeExtGet('androidxCoreVersion')
|
def androidxCore_version = safeExtGet('androidxCoreVersion')
|
||||||
def androidxActivity_version = safeExtGet('androidxActivityVersion')
|
def androidxActivity_version = safeExtGet('androidxActivityVersion')
|
||||||
|
|
||||||
@ -239,7 +261,7 @@ dependencies {
|
|||||||
implementation "androidx.media3:media3-exoplayer-rtsp:$media3_version"
|
implementation "androidx.media3:media3-exoplayer-rtsp:$media3_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For ad insertion using the Interactive Media Ads SDK with ExoPlayer
|
// For ad insertion using the Interactive Media Ads SDK with ExoPlayer
|
||||||
if (ExoplayerDependencies["useExoplayerIMA"]) {
|
if (ExoplayerDependencies["useExoplayerIMA"]) {
|
||||||
if (media3_buildFromSource) {
|
if (media3_buildFromSource) {
|
||||||
@ -280,5 +302,4 @@ dependencies {
|
|||||||
// Common functionality used across multiple media libraries
|
// Common functionality used across multiple media libraries
|
||||||
implementation "androidx.media3:media3-common:$media3_version"
|
implementation "androidx.media3:media3-common:$media3_version"
|
||||||
}
|
}
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
}
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
RNVideo_kotlinVersion=1.7.0
|
RNVideo_kotlinVersion=1.8.0
|
||||||
RNVideo_minSdkVersion=23
|
RNVideo_minSdkVersion=23
|
||||||
RNVideo_targetSdkVersion=34
|
RNVideo_targetSdkVersion=34
|
||||||
RNVideo_compileSdkVersion=34
|
RNVideo_compileSdkVersion=34
|
||||||
|
@ -91,13 +91,12 @@ class FullScreenPlayerView(
|
|||||||
parent = null
|
parent = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getFullscreenIconResource(isFullscreen: Boolean): Int {
|
private fun getFullscreenIconResource(isFullscreen: Boolean): Int =
|
||||||
return if (isFullscreen) {
|
if (isFullscreen) {
|
||||||
androidx.media3.ui.R.drawable.exo_icon_fullscreen_exit
|
androidx.media3.ui.R.drawable.exo_icon_fullscreen_exit
|
||||||
} else {
|
} else {
|
||||||
androidx.media3.ui.R.drawable.exo_icon_fullscreen_enter
|
androidx.media3.ui.R.drawable.exo_icon_fullscreen_enter
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateFullscreenButton(playerControlView: LegacyPlayerControlView, isFullscreen: Boolean) {
|
private fun updateFullscreenButton(playerControlView: LegacyPlayerControlView, isFullscreen: Boolean) {
|
||||||
val imageButton = playerControlView.findViewById<ImageButton?>(com.brentvatne.react.R.id.exo_fullscreen)
|
val imageButton = playerControlView.findViewById<ImageButton?>(com.brentvatne.react.R.id.exo_fullscreen)
|
||||||
|
@ -57,12 +57,14 @@ $RNVideoUseGoogleIMA=true
|
|||||||
|
|
||||||
## Android
|
## 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 {
|
buildscript {
|
||||||
...
|
...
|
||||||
ext.kotlinVersion = '1.7.0'
|
ext.kotlinVersion = '1.8.0',
|
||||||
|
ext.compileSdkVersion = 34
|
||||||
|
ext.targetSdkVersion = 34
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user