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")
|
signingConfig = signingConfigs.getByName("debug")
|
||||||
|
|
||||||
postprocessing {
|
optimization {
|
||||||
isRemoveUnusedCode = true
|
enable = true
|
||||||
isObfuscate = false
|
keepRules {
|
||||||
isOptimizeCode = true
|
files.add(File(projectDir, "proguard-rules.pro"))
|
||||||
isRemoveUnusedResources = true
|
files.add(getDefaultProguardFile("proguard-android-optimize.txt"))
|
||||||
proguardFiles("proguard-rules.pro")
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,10 +152,6 @@ android {
|
|||||||
matchingFallbacks += listOf("release")
|
matchingFallbacks += listOf("release")
|
||||||
signingConfig = signingConfigs.getByName("nightly")
|
signingConfig = signingConfigs.getByName("nightly")
|
||||||
|
|
||||||
postprocessing {
|
|
||||||
initWith(release.postprocessing)
|
|
||||||
}
|
|
||||||
|
|
||||||
firebaseAppDistribution {
|
firebaseAppDistribution {
|
||||||
artifactType = "APK"
|
artifactType = "APK"
|
||||||
// We upload the universal APK to fix this error:
|
// We upload the universal APK to fix this error:
|
||||||
@@ -341,7 +337,7 @@ fun Project.configureLicensesTasks(reportingExtension: ReportingExtension) {
|
|||||||
it.toString()
|
it.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val artifactsFile = reportingExtension.file("licensee/android$capitalizedVariantName/artifacts.json")
|
val artifactsFile = reportingExtension.baseDirectory.file("licensee/android$capitalizedVariantName/artifacts.json")
|
||||||
|
|
||||||
val copyArtifactsTask =
|
val copyArtifactsTask =
|
||||||
project.tasks.register<AssetCopyTask>("copy${capitalizedVariantName}LicenseeReportToAssets") {
|
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);
|
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 LogSessionId class and related classes (https://github.com/androidx/media/issues/2535)
|
||||||
-keep class android.media.metrics.LogSessionId { *; }
|
-keep class android.media.metrics.LogSessionId { *; }
|
||||||
@@ -51,3 +49,24 @@
|
|||||||
# Keep Media3 classes that use reflection (https://github.com/androidx/media/issues/2535)
|
# Keep Media3 classes that use reflection (https://github.com/androidx/media/issues/2535)
|
||||||
-keep class androidx.media3.** { *; }
|
-keep class androidx.media3.** { *; }
|
||||||
-dontwarn android.media.metrics.**
|
-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
|
# Let test include roborazzi verification
|
||||||
# https://github.com/takahirom/roborazzi?tab=readme-ov-file#roborazzitest
|
# https://github.com/takahirom/roborazzi?tab=readme-ov-file#roborazzitest
|
||||||
roborazzi.test.verify=true
|
roborazzi.test.verify=true
|
||||||
|
|
||||||
|
# Needed after enabling proguard on AGP 8.13.1
|
||||||
|
android.r8.gradual.support=true
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
|
|
||||||
[versions]
|
[versions]
|
||||||
# Project
|
# 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.13.1"
|
||||||
android_gradle_plugin = "8.11.1"
|
|
||||||
# When updateing this, please also update the version in the file ./idea/kotlinc.xml
|
# When updateing this, please also update the version in the file ./idea/kotlinc.xml
|
||||||
kotlin = "2.2.20"
|
kotlin = "2.2.20"
|
||||||
kotlinpoet = "2.2.0"
|
kotlinpoet = "2.2.0"
|
||||||
|
|||||||
@@ -155,16 +155,16 @@ inline fun <T> MutableState<AsyncAction<T>>.runUpdatingStateNoSuccess(
|
|||||||
* @param resultBlock a suspending function that returns a [Result].
|
* @param resultBlock a suspending function that returns a [Result].
|
||||||
* @return the [Result] returned by [resultBlock].
|
* @return the [Result] returned by [resultBlock].
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
||||||
suspend inline fun <T> runUpdatingState(
|
suspend inline fun <T> runUpdatingState(
|
||||||
state: MutableState<AsyncAction<T>>,
|
state: MutableState<AsyncAction<T>>,
|
||||||
errorTransform: (Throwable) -> Throwable = { it },
|
errorTransform: (Throwable) -> Throwable = { it },
|
||||||
resultBlock: suspend () -> Result<T>,
|
resultBlock: suspend () -> Result<T>,
|
||||||
): Result<T> {
|
): Result<T> {
|
||||||
contract {
|
// Restore when the issue with contracts and AGP 8.13.x is fixed
|
||||||
callsInPlace(resultBlock, InvocationKind.EXACTLY_ONCE)
|
// contract {
|
||||||
}
|
// callsInPlace(resultBlock, InvocationKind.EXACTLY_ONCE)
|
||||||
|
// }
|
||||||
state.value = AsyncAction.Loading
|
state.value = AsyncAction.Loading
|
||||||
return try {
|
return try {
|
||||||
resultBlock()
|
resultBlock()
|
||||||
|
|||||||
@@ -11,9 +11,6 @@ package io.element.android.libraries.architecture
|
|||||||
import androidx.compose.runtime.MutableState
|
import androidx.compose.runtime.MutableState
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import io.element.android.libraries.core.extensions.runCatchingExceptions
|
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.
|
* 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].
|
* @param resultBlock a suspending function that returns a [Result].
|
||||||
* @return the [Result] returned by [resultBlock].
|
* @return the [Result] returned by [resultBlock].
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
||||||
suspend inline fun <T> runUpdatingState(
|
suspend inline fun <T> runUpdatingState(
|
||||||
state: MutableState<AsyncData<T>>,
|
state: MutableState<AsyncData<T>>,
|
||||||
errorTransform: (Throwable) -> Throwable = { it },
|
errorTransform: (Throwable) -> Throwable = { it },
|
||||||
resultBlock: suspend () -> Result<T>,
|
resultBlock: suspend () -> Result<T>,
|
||||||
): Result<T> {
|
): Result<T> {
|
||||||
contract {
|
// Restore when the issue with contracts and AGP 8.13.x is fixed
|
||||||
callsInPlace(resultBlock, InvocationKind.EXACTLY_ONCE)
|
// contract {
|
||||||
}
|
// callsInPlace(resultBlock, InvocationKind.EXACTLY_ONCE)
|
||||||
|
// }
|
||||||
val prevData = state.value.dataOrNull()
|
val prevData = state.value.dataOrNull()
|
||||||
state.value = AsyncData.Loading(prevData = prevData)
|
state.value = AsyncData.Loading(prevData = prevData)
|
||||||
return resultBlock().fold(
|
return resultBlock().fold(
|
||||||
|
|||||||
Reference in New Issue
Block a user