Skip to content

Commit

Permalink
[android] fix Android 14
Browse files Browse the repository at this point in the history
  • Loading branch information
lightrow committed Jul 30, 2024
1 parent 81fad0c commit 6b3e12f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 4 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def safeExtGet(prop, fallback) {
}

android {
compileSdkVersion safeExtGet('compileSdkVersion', 28)
buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
compileSdkVersion safeExtGet('compileSdkVersion', 34)
buildToolsVersion safeExtGet('buildToolsVersion', '34.0.0')

compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
Expand All @@ -15,7 +15,7 @@ android {

defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 24)
targetSdkVersion safeExtGet('targetSdkVersion', 28)
targetSdkVersion safeExtGet('targetSdkVersion', 34)
versionCode 1
versionName "1.0"
}
Expand Down Expand Up @@ -51,7 +51,7 @@ dependencies {

// All support libs must use the same version
implementation "androidx.annotation:annotation:1.1.0"
implementation "androidx.core:core:1.1.0"
implementation "androidx.core:core:1.12.0"
implementation "androidx.media:media:1.1.0"
implementation "androidx.activity:activity:1.4.0"

Expand Down
4 changes: 3 additions & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
package="com.brentvatne.react">
<application>
<service android:name="com.brentvatne.exoplayer.persistencemanager.AssetDownloadService"
android:exported="false">
android:exported="false"
android:foregroundServiceType="dataSync">
<!-- This is needed for Scheduler -->
<intent-filter>
<action android:name="com.google.android.exoplayer.downloadService.action.RESTART"/>
Expand All @@ -16,4 +17,5 @@
</application>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.net.Uri;
import androidx.annotation.Nullable;
import android.content.pm.ServiceInfo;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Promise;
Expand Down Expand Up @@ -45,7 +46,11 @@ public AssetPersistenceManager(ReactApplicationContext appContext) {
try {
DownloadService.start(appContext, AssetDownloadService.class);
} catch (IllegalStateException e) {
DownloadService.startForeground(appContext, AssetDownloadService.class);
if (Build.VERSION.SDK_INT >= 34) {
DownloadService.startForeground(appContext, AssetDownloadService.class, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC);
} else {
DownloadService.startForeground(appContext, AssetDownloadService.class);
}
}
}

Expand Down

0 comments on commit 6b3e12f

Please sign in to comment.