diff --git a/android/build.gradle b/android/build.gradle index 40c7f487..443d0557 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -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() @@ -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) { @@ -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() @@ -39,7 +40,7 @@ def supportsNamespace() { return major >= 8 } -def useExoplayerIMA = safeExtGet("RNVUseExoplayerIMA", false) +def useExoplayerIMA = getExtOrDefault("RNVUseExoplayerIMA", false) println "useExoplayerIMA:" + useExoplayerIMA @@ -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 @@ -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() @@ -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' } diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 00000000..fda29955 --- /dev/null +++ b/android/gradle.properties @@ -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 \ No newline at end of file diff --git a/docs/pages/installation.md b/docs/pages/installation.md index 49d7370f..cc9194a4 100644 --- a/docs/pages/installation.md +++ b/docs/pages/installation.md @@ -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: