From dc144614901a084af09e4b2a54d266b015ac1195 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Sat, 13 Jul 2024 09:01:53 +0000 Subject: [PATCH 1/2] Update retrofit from 2.9.0 to 2.11.0 - Replace Jake Wharton's Kotlinx Serialization converter with new retrofit's `converter-kotlinx-serialization`. - Remove custom Proguard rules that are now part of the dependency: https://github.com/square/retrofit/tree/trunk/retrofit-response-type-keeper#readme Changelog: https://github.com/square/retrofit/blob/trunk/CHANGELOG.md --- app/build.gradle.kts | 2 +- app/dependencies/prodReleaseRuntimeClasspath.txt | 4 ++-- app/proguard-rules.pro | 9 --------- .../core/network/retrofit/RetrofitNiaNetwork.kt | 2 +- gradle/libs.versions.toml | 4 ++-- 5 files changed, 6 insertions(+), 15 deletions(-) delete mode 100644 app/proguard-rules.pro diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 92f3f549b..4fc2ea36c 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -48,7 +48,7 @@ android { release { isMinifyEnabled = true applicationIdSuffix = NiaBuildType.RELEASE.applicationIdSuffix - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt")) // To publish on the Play store a private signing key is required, but to allow anyone // who clones the code to sign and run the release variant, use the debug signing key. diff --git a/app/dependencies/prodReleaseRuntimeClasspath.txt b/app/dependencies/prodReleaseRuntimeClasspath.txt index e1c0a6f60..96f888117 100644 --- a/app/dependencies/prodReleaseRuntimeClasspath.txt +++ b/app/dependencies/prodReleaseRuntimeClasspath.txt @@ -190,12 +190,12 @@ com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava com.google.j2objc:j2objc-annotations:1.3 com.google.protobuf:protobuf-javalite:4.26.1 com.google.protobuf:protobuf-kotlin-lite:4.26.1 -com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0 +com.squareup.retrofit2:converter-kotlinx-serialization:2.11.0 com.squareup.okhttp3:logging-interceptor:4.12.0 com.squareup.okhttp3:okhttp:4.12.0 com.squareup.okio:okio-jvm:3.9.0 com.squareup.okio:okio:3.9.0 -com.squareup.retrofit2:retrofit:2.9.0 +com.squareup.retrofit2:retrofit:2.10.0 io.coil-kt:coil-base:2.7.0 io.coil-kt:coil-compose-base:2.7.0 io.coil-kt:coil-compose:2.7.0 diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro deleted file mode 100644 index 5f4922bce..000000000 --- a/app/proguard-rules.pro +++ /dev/null @@ -1,9 +0,0 @@ -# Fix for Retrofit issue https://github.com/square/retrofit/issues/3751 -# Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items). --keep,allowobfuscation,allowshrinking interface retrofit2.Call --keep,allowobfuscation,allowshrinking class retrofit2.Response - -# With R8 full mode generic signatures are stripped for classes that are not -# kept. Suspend functions are wrapped in continuations where the type argument -# is used. --keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation diff --git a/core/network/src/main/kotlin/com/google/samples/apps/nowinandroid/core/network/retrofit/RetrofitNiaNetwork.kt b/core/network/src/main/kotlin/com/google/samples/apps/nowinandroid/core/network/retrofit/RetrofitNiaNetwork.kt index e9fe99d9e..bdd852f8b 100644 --- a/core/network/src/main/kotlin/com/google/samples/apps/nowinandroid/core/network/retrofit/RetrofitNiaNetwork.kt +++ b/core/network/src/main/kotlin/com/google/samples/apps/nowinandroid/core/network/retrofit/RetrofitNiaNetwork.kt @@ -22,12 +22,12 @@ import com.google.samples.apps.nowinandroid.core.network.NiaNetworkDataSource import com.google.samples.apps.nowinandroid.core.network.model.NetworkChangeList import com.google.samples.apps.nowinandroid.core.network.model.NetworkNewsResource import com.google.samples.apps.nowinandroid.core.network.model.NetworkTopic -import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json import okhttp3.Call import okhttp3.MediaType.Companion.toMediaType import retrofit2.Retrofit +import retrofit2.converter.kotlinx.serialization.asConverterFactory import retrofit2.http.GET import retrofit2.http.Query import javax.inject.Inject diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 128a4af05..062150292 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -48,7 +48,7 @@ moduleGraph = "2.5.0" okhttp = "4.12.0" protobuf = "4.26.1" protobufPlugin = "0.9.4" -retrofit = "2.9.0" +retrofit = "2.11.0" retrofitKotlinxSerializationJson = "1.0.0" robolectric = "4.12.2" roborazzi = "1.7.0" @@ -139,7 +139,7 @@ okhttp-logging = { group = "com.squareup.okhttp3", name = "logging-interceptor", protobuf-kotlin-lite = { group = "com.google.protobuf", name = "protobuf-kotlin-lite", version.ref = "protobuf" } protobuf-protoc = { group = "com.google.protobuf", name = "protoc", version.ref = "protobuf" } retrofit-core = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" } -retrofit-kotlin-serialization = { group = "com.jakewharton.retrofit", name = "retrofit2-kotlinx-serialization-converter", version.ref = "retrofitKotlinxSerializationJson" } +retrofit-kotlin-serialization = { group = "com.squareup.retrofit2", name = "converter-kotlinx-serialization", version.ref = "retrofit" } robolectric = { group = "org.robolectric", name = "robolectric", version.ref = "robolectric" } roborazzi = { group = "io.github.takahirom.roborazzi", name = "roborazzi", version.ref = "roborazzi" } room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" } From 2b625cbb17b0ce50b29326b780d1712921ea2714 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Thu, 5 Sep 2024 19:08:07 +0100 Subject: [PATCH 2/2] Update app/dependencies/prodReleaseRuntimeClasspath.txt --- app/dependencies/prodReleaseRuntimeClasspath.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/dependencies/prodReleaseRuntimeClasspath.txt b/app/dependencies/prodReleaseRuntimeClasspath.txt index 96f888117..cb937de4e 100644 --- a/app/dependencies/prodReleaseRuntimeClasspath.txt +++ b/app/dependencies/prodReleaseRuntimeClasspath.txt @@ -195,7 +195,7 @@ com.squareup.okhttp3:logging-interceptor:4.12.0 com.squareup.okhttp3:okhttp:4.12.0 com.squareup.okio:okio-jvm:3.9.0 com.squareup.okio:okio:3.9.0 -com.squareup.retrofit2:retrofit:2.10.0 +com.squareup.retrofit2:retrofit:2.11.0 io.coil-kt:coil-base:2.7.0 io.coil-kt:coil-compose-base:2.7.0 io.coil-kt:coil-compose:2.7.0