fix(deps): update android.gradle.plugin to v8.13.1 (#5260)
* fix(deps): update android.gradle.plugin to v8.13.1 * Remove warning about AGP 8.12.x+ * Fix proguard-related code deprecations, use the new `optimization` API * Workaround issues related to Android lint not being able to check these complex methods with kotlin contracts --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jorge Martín <jorgem@element.io>
This commit is contained in:
@@ -129,12 +129,12 @@ android {
|
||||
)
|
||||
signingConfig = signingConfigs.getByName("debug")
|
||||
|
||||
postprocessing {
|
||||
isRemoveUnusedCode = true
|
||||
isObfuscate = false
|
||||
isOptimizeCode = true
|
||||
isRemoveUnusedResources = true
|
||||
proguardFiles("proguard-rules.pro")
|
||||
optimization {
|
||||
enable = true
|
||||
keepRules {
|
||||
files.add(File(projectDir, "proguard-rules.pro"))
|
||||
files.add(getDefaultProguardFile("proguard-android-optimize.txt"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,10 +152,6 @@ android {
|
||||
matchingFallbacks += listOf("release")
|
||||
signingConfig = signingConfigs.getByName("nightly")
|
||||
|
||||
postprocessing {
|
||||
initWith(release.postprocessing)
|
||||
}
|
||||
|
||||
firebaseAppDistribution {
|
||||
artifactType = "APK"
|
||||
// We upload the universal APK to fix this error:
|
||||
@@ -341,7 +337,7 @@ fun Project.configureLicensesTasks(reportingExtension: ReportingExtension) {
|
||||
it.toString()
|
||||
}
|
||||
}
|
||||
val artifactsFile = reportingExtension.file("licensee/android$capitalizedVariantName/artifacts.json")
|
||||
val artifactsFile = reportingExtension.baseDirectory.file("licensee/android$capitalizedVariantName/artifacts.json")
|
||||
|
||||
val copyArtifactsTask =
|
||||
project.tasks.register<AssetCopyTask>("copy${capitalizedVariantName}LicenseeReportToAssets") {
|
||||
|
||||
23
app/proguard-rules.pro
vendored
23
app/proguard-rules.pro
vendored
@@ -41,8 +41,6 @@
|
||||
static int windowAttachCount(android.view.View);
|
||||
}
|
||||
|
||||
-keep class io.element.android.x.di.** { *; }
|
||||
|
||||
|
||||
# Keep LogSessionId class and related classes (https://github.com/androidx/media/issues/2535)
|
||||
-keep class android.media.metrics.LogSessionId { *; }
|
||||
@@ -51,3 +49,24 @@
|
||||
# Keep Media3 classes that use reflection (https://github.com/androidx/media/issues/2535)
|
||||
-keep class androidx.media3.** { *; }
|
||||
-dontwarn android.media.metrics.**
|
||||
|
||||
# New rules after AGP 8.13.1 upgrade
|
||||
-dontwarn androidx.window.extensions.WindowExtensions
|
||||
-dontwarn androidx.window.extensions.WindowExtensionsProvider
|
||||
-dontwarn androidx.window.extensions.area.ExtensionWindowAreaPresentation
|
||||
-dontwarn androidx.window.extensions.layout.DisplayFeature
|
||||
-dontwarn androidx.window.extensions.layout.FoldingFeature
|
||||
-dontwarn androidx.window.extensions.layout.WindowLayoutComponent
|
||||
-dontwarn androidx.window.extensions.layout.WindowLayoutInfo
|
||||
-dontwarn androidx.window.sidecar.SidecarDeviceState
|
||||
-dontwarn androidx.window.sidecar.SidecarDisplayFeature
|
||||
-dontwarn androidx.window.sidecar.SidecarInterface$SidecarCallback
|
||||
-dontwarn androidx.window.sidecar.SidecarInterface
|
||||
-dontwarn androidx.window.sidecar.SidecarProvider
|
||||
-dontwarn androidx.window.sidecar.SidecarWindowLayoutInfo
|
||||
|
||||
# Also needed after AGP 8.13.1 upgrade, it seems like proguard is now more aggressive on removing unused code
|
||||
-keep class org.matrix.rustcomponents.sdk.** { *;}
|
||||
-keep class uniffi.** { *;}
|
||||
-keep class io.element.android.x.di.** { *; }
|
||||
-keepnames class io.element.android.x.**
|
||||
|
||||
@@ -59,3 +59,6 @@ detekt.use.worker.api=true
|
||||
# Let test include roborazzi verification
|
||||
# https://github.com/takahirom/roborazzi?tab=readme-ov-file#roborazzitest
|
||||
roborazzi.test.verify=true
|
||||
|
||||
# Needed after enabling proguard on AGP 8.13.1
|
||||
android.r8.gradual.support=true
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
|
||||
[versions]
|
||||
# Project
|
||||
# We cannot use 8.12.+ since it breaks F-Droid build (see https://github.com/element-hq/element-x-android/issues/3420#issuecomment-3199571010)
|
||||
android_gradle_plugin = "8.11.1"
|
||||
android_gradle_plugin = "8.13.1"
|
||||
# When updateing this, please also update the version in the file ./idea/kotlinc.xml
|
||||
kotlin = "2.2.20"
|
||||
kotlinpoet = "2.2.0"
|
||||
|
||||
@@ -155,16 +155,16 @@ inline fun <T> MutableState<AsyncAction<T>>.runUpdatingStateNoSuccess(
|
||||
* @param resultBlock a suspending function that returns a [Result].
|
||||
* @return the [Result] returned by [resultBlock].
|
||||
*/
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
||||
suspend inline fun <T> runUpdatingState(
|
||||
state: MutableState<AsyncAction<T>>,
|
||||
errorTransform: (Throwable) -> Throwable = { it },
|
||||
resultBlock: suspend () -> Result<T>,
|
||||
): Result<T> {
|
||||
contract {
|
||||
callsInPlace(resultBlock, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
// Restore when the issue with contracts and AGP 8.13.x is fixed
|
||||
// contract {
|
||||
// callsInPlace(resultBlock, InvocationKind.EXACTLY_ONCE)
|
||||
// }
|
||||
state.value = AsyncAction.Loading
|
||||
return try {
|
||||
resultBlock()
|
||||
|
||||
@@ -11,9 +11,6 @@ package io.element.android.libraries.architecture
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.Stable
|
||||
import io.element.android.libraries.core.extensions.runCatchingExceptions
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.InvocationKind
|
||||
import kotlin.contracts.contract
|
||||
|
||||
/**
|
||||
* Sealed type that allows to model an asynchronous operation.
|
||||
@@ -134,16 +131,16 @@ suspend inline fun <T> MutableState<AsyncData<T>>.runUpdatingState(
|
||||
* @param resultBlock a suspending function that returns a [Result].
|
||||
* @return the [Result] returned by [resultBlock].
|
||||
*/
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
||||
suspend inline fun <T> runUpdatingState(
|
||||
state: MutableState<AsyncData<T>>,
|
||||
errorTransform: (Throwable) -> Throwable = { it },
|
||||
resultBlock: suspend () -> Result<T>,
|
||||
): Result<T> {
|
||||
contract {
|
||||
callsInPlace(resultBlock, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
// Restore when the issue with contracts and AGP 8.13.x is fixed
|
||||
// contract {
|
||||
// callsInPlace(resultBlock, InvocationKind.EXACTLY_ONCE)
|
||||
// }
|
||||
val prevData = state.value.dataOrNull()
|
||||
state.value = AsyncData.Loading(prevData = prevData)
|
||||
return resultBlock().fold(
|
||||
|
||||
Reference in New Issue
Block a user