Skip to content

Commit

Permalink
chore(android): bump kotlin version (#3334)
Browse files Browse the repository at this point in the history
* chore(android): update gradle files

* docs: update android installation section
  • Loading branch information
KrzysztofMoch authored Nov 8, 2023
1 parent 722ae34 commit 6df0f7d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
30 changes: 17 additions & 13 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import com.android.Version

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

buildscript {
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') :
(project.properties['RNSAC_kotlinVersion'] ? project.properties['RNSAC_kotlinVersion'] : "1.6.10")
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['RNVideo_kotlinVersion']

repositories {
mavenCentral()
Expand All @@ -14,8 +15,8 @@ buildscript {
}
}

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
def safeExtGet(prop) {
return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : project.properties["RNVideo_" + prop]
}

def getExtOrDefault(name, defaultValue) {
Expand All @@ -27,7 +28,7 @@ def isNewArchitectureEnabled() {
}

def supportsNamespace() {
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
def parsed = Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
def major = parsed[0].toInteger()
def minor = parsed[1].toInteger()

Expand All @@ -39,7 +40,7 @@ def supportsNamespace() {
return major >= 8
}

def useExoplayerIMA = safeExtGet("RNVUseExoplayerIMA", false)
def useExoplayerIMA = getExtOrDefault("RNVUseExoplayerIMA", false)

println "useExoplayerIMA:" + useExoplayerIMA

Expand All @@ -66,10 +67,10 @@ android {
}
}

compileSdkVersion safeExtGet('compileSdkVersion', 31)
buildToolsVersion safeExtGet('buildToolsVersion', '30.0.2')
compileSdkVersion safeExtGet('compileSdkVersion')
buildToolsVersion safeExtGet('buildToolsVersion')

def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
def agpVersion = Version.ANDROID_GRADLE_PLUGIN_VERSION
if (agpVersion.tokenize('.')[0].toInteger() < 8) {
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
Expand All @@ -82,8 +83,8 @@ android {
}

defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 21)
targetSdkVersion safeExtGet('targetSdkVersion', 28)
minSdkVersion safeExtGet('minSdkVersion')
targetSdkVersion safeExtGet('targetSdkVersion')
versionCode 1
versionName "1.0"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
Expand Down Expand Up @@ -144,10 +145,13 @@ repositories {
mavenCentral()
}

def kotlin_version = getExtOrDefault('kotlinVersion', project.properties['RNSAC_kotlinVersion'])
def kotlin_version = safeExtGet('kotlinVersion')

dependencies {
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
// For < 0.71, this will be from the local maven repo
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation('com.google.android.exoplayer:exoplayer:2.18.1') {
exclude group: 'com.android.support'
}
Expand Down
6 changes: 6 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
RNVideo_kotlinVersion=1.7.0
RNVideo_minSdkVersion=21
RNVideo_targetSdkVersion=31
RNVideo_compileSdkVersion=31
RNVideo_ndkversion=21.4.7075529
RNVideo_buildToolsVersion=30.0.2
12 changes: 12 additions & 0 deletions docs/pages/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android')
```

`android/build.gradle`

From version >= 6.0.0, your application needs to have kotlin version >= 1.7.0

```:
buildscript {
...
ext.kotlinVersion = '1.7.0'
...
}
```

`android/app/build.gradle`

From version >= 5.0.0, you have to apply these changes:
Expand Down

0 comments on commit 6df0f7d

Please sign in to comment.