Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): ads build and enable ads in android sample #3376

Merged
merged 9 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion android/build.gradle
freeboub marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,15 @@ repositories {

def media3_version = safeExtGet('media3Version')
def kotlin_version = safeExtGet('kotlinVersion')
def androidxCode_version = safeExtGet('androidxCore')
freeboub marked this conversation as resolved.
Show resolved Hide resolved

dependencies {
// 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 "androidx.core:core:1.9.0"
implementation "androidx.core:core:$androidxCode_version"

// For media playback using ExoPlayer
implementation "androidx.media3:media3-exoplayer:$media3_version"
Expand Down
3 changes: 2 additions & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ RNVideo_compileSdkVersion=31
RNVideo_ndkversion=21.4.7075529
RNVideo_buildToolsVersion=30.0.2
RNVideo_media3Version=1.1.1
RNVideo_RNVUseExoplayerIMA=false
RNVideo_RNVUseExoplayerIMA=false
RNVideo_androidxCore=1.9.0
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
import androidx.media3.extractor.metadata.id3.Id3Frame;
import androidx.media3.extractor.metadata.id3.TextInformationFrame;
import androidx.media3.ui.LegacyPlayerControlView;
import androidx.media3.exoplayer.ima.ImaAdsLoader;

import com.brentvatne.common.API.ResizeMode;
import com.brentvatne.common.API.SubtitleStyle;
Expand All @@ -103,7 +104,6 @@
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.uimanager.ThemedReactContext;
import com.google.ads.interactivemedia.v3.api.AdEvent;
import com.google.android.exoplayer2.ext.ima.ImaAdsLoader;
freeboub marked this conversation as resolved.
Show resolved Hide resolved
import com.google.common.collect.ImmutableList;

import java.net.CookieHandler;
Expand Down
13 changes: 13 additions & 0 deletions examples/basic/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,12 @@ android {
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
configurations.all {
resolutionStrategy { force 'androidx.core:core:1.9.0' }
}
}


dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
Expand All @@ -120,6 +124,15 @@ dependencies {
}

implementation project(':react-native-video')

constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
}
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
}
}
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
4 changes: 3 additions & 1 deletion examples/basic/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ buildscript {
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
kotlinVersion = "1.6.20"
kotlinVersion = "1.8.0"

// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"

RNVUseExoplayerIMA = true
}
repositories {
google()
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/src/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ class VideoPlayer extends Component {
this.video = ref;
}}
source={this.srcList[this.state.srcListId]}
//adTagUrl={this.srcList[this.state.srcListId]?.adTagUrl}
adTagUrl={this.srcList[this.state.srcListId]?.adTagUrl}
style={viewStyle}
rate={this.state.rate}
paused={this.state.paused}
Expand Down