diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8187d7e6c..02229f6a6 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -162,7 +162,6 @@ dependencies { ksp(libs.google.hilt.compiler) implementation(libs.google.guava) implementation(libs.google.protobuf.javalite) - implementation(libs.jakewharton.retrofit.kotlinx.serialization) implementation(libs.kotlinx.collections.immutable) implementation(libs.kotlinx.coroutines.android) implementation(libs.kotlinx.serialization.json) diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 1648caf60..73aed837e 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -74,6 +74,33 @@ @com.sun.jna.* *; } +################################################################################ +# Okhttp/Retrofit https://square.github.io/okhttp/ & https://square.github.io/retrofit/ +################################################################################ + +# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and +# EnclosingMethod is required to use InnerClasses. +-keepattributes Signature, InnerClasses, EnclosingMethod + +# Retrofit does reflection on method and parameter annotations. +-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations + +# https://github.com/square/okhttp/blob/339732e3a1b78be5d792860109047f68a011b5eb/okhttp/src/jvmMain/resources/META-INF/proguard/okhttp3.pro#L11-L14 +-dontwarn okhttp3.internal.platform.** +-dontwarn org.bouncycastle.** +# Related to this issue on https://github.com/square/retrofit/issues/3880 +# Check https://github.com/square/retrofit/tags for new versions +-keep,allowobfuscation,allowshrinking class kotlin.Result +-keep,allowobfuscation,allowshrinking interface retrofit2.Call +-keep,allowobfuscation,allowshrinking class retrofit2.Response +# This solves this issue https://github.com/square/retrofit/issues/3880 +-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation + +# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy +# and replaces all potential values with null. Explicitly keeping the interfaces prevents this. +-if interface * { @retrofit2.http.* ; } +-keep,allowobfuscation interface <1> + ################################################################################ # ZXing ################################################################################ diff --git a/app/src/main/kotlin/com/bitwarden/authenticator/data/platform/datasource/network/retrofit/RetrofitsImpl.kt b/app/src/main/kotlin/com/bitwarden/authenticator/data/platform/datasource/network/retrofit/RetrofitsImpl.kt index 058d6253c..8dff34eff 100644 --- a/app/src/main/kotlin/com/bitwarden/authenticator/data/platform/datasource/network/retrofit/RetrofitsImpl.kt +++ b/app/src/main/kotlin/com/bitwarden/authenticator/data/platform/datasource/network/retrofit/RetrofitsImpl.kt @@ -4,11 +4,11 @@ import com.bitwarden.authenticator.data.platform.datasource.network.core.ResultC import com.bitwarden.authenticator.data.platform.datasource.network.interceptor.BaseUrlInterceptor import com.bitwarden.authenticator.data.platform.datasource.network.interceptor.BaseUrlInterceptors import com.bitwarden.authenticator.data.platform.datasource.network.interceptor.HeadersInterceptor -import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory import kotlinx.serialization.json.Json import okhttp3.MediaType.Companion.toMediaType import okhttp3.OkHttpClient import retrofit2.Retrofit +import retrofit2.converter.kotlinx.serialization.asConverterFactory /** * Primary implementation of [Retrofits]. diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8879303ce..fa8cf9c4d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -48,9 +48,7 @@ kotlinxKover = "0.8.3" ksp = "2.0.21-1.0.27" mockk = "1.13.13" okhttp = "4.12.0" -retrofit = "2.11.0" retrofitBom = "2.11.0" -retrofitKotlinxSerialization = "1.0.0" roboelectric = "4.13" sonarqube = "5.1.0.4882" turbine = "1.2.0" @@ -107,7 +105,6 @@ google-hilt-compiler = { module = "com.google.dagger:hilt-android-compiler", ver google-protobuf-javalite = { module = "com.google.protobuf:protobuf-javalite", version.ref = "googleProtoBufJava" } # Included so that Renovate tracks updates since protoc is not referenced directly in `dependency {}` blocks. google-protobuf-protoc = { module = "com.google.protobuf:protoc", version.ref = "googleProtoBufJava" } -jakewharton-retrofit-kotlinx-serialization = { module = "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter", version.ref = "retrofitKotlinxSerialization" } junit-junit5 = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit5" } junit-vintage = { module = "org.junit.vintage:junit-vintage-engine", version.ref = "junit5" } kotlinx-collections-immutable = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version.ref = "kotlinxCollectionsImmutable" } @@ -120,7 +117,7 @@ robolectric-robolectric = { module = "org.robolectric:robolectric", version.ref square-okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } square-okhttp-logging = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" } square-okhttp-mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "okhttp" } -square-retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" } +square-retrofit = { module = "com.squareup.retrofit2:retrofit" } square-retrofit-bom = { module = "com.squareup.retrofit2:retrofit-bom", version.ref = "retrofitBom" } square-retrofit-kotlinx-serialization = { module = "com.squareup.retrofit2:converter-kotlinx-serialization" } square-turbine = { module = "app.cash.turbine:turbine", version.ref = "turbine" }