Skip to content

Commit

Permalink
fix: signed build issue with R8 full mode
Browse files Browse the repository at this point in the history
fixes: LEARNER-10122
  • Loading branch information
farhan-arshad-dev committed Jul 31, 2024
1 parent 90f976b commit 1cfb1f8
Show file tree
Hide file tree
Showing 19 changed files with 379 additions and 96 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ android {
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', '../shared-proguard-rules.pro'

if (firebaseEnabled) {
firebaseCrashlytics {
Expand Down
113 changes: 33 additions & 80 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -20,92 +20,45 @@
# hide the original source file name.
#-renamesourcefileattribute SourceFile

#====================/////Retrofit Rules\\\\\===============
# 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

# Keep annotation default values (e.g., retrofit2.http.Field.encoded).
-keepattributes AnnotationDefault

# Retain service method parameters when optimizing.
-keepclassmembers,allowshrinking,allowobfuscation interface * {
@retrofit2.http.* <methods>;
}

# Ignore JSR 305 annotations for embedding nullability information.
-dontwarn javax.annotation.**

# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
-dontwarn kotlin.Unit

# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.KotlinExtensions
-dontwarn retrofit2.KotlinExtensions$*

# 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.* <methods>; }
-keep,allowobfuscation interface <1>

# 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

#===============/////GSON RULES \\\\\\\============
##---------------Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class org.openedx.*.data.model.** { <fields>; }

# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * extends com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}

# Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher.
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken

##---------------End: proguard configuration for Gson ----------

-keepclassmembers class * extends java.lang.Enum {
<fields>;
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class org.openedx.app.AppActivity

-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
-dontwarn org.bouncycastle.asn1.ASN1Encodable
-dontwarn org.bouncycastle.asn1.pkcs.PrivateKeyInfo
-dontwarn org.bouncycastle.asn1.x509.AlgorithmIdentifier
-dontwarn org.bouncycastle.asn1.x509.SubjectPublicKeyInfo
-dontwarn org.bouncycastle.cert.X509CertificateHolder
-dontwarn org.bouncycastle.cert.jcajce.JcaX509CertificateHolder
-dontwarn org.bouncycastle.crypto.BlockCipher
-dontwarn org.bouncycastle.crypto.CipherParameters
-dontwarn org.bouncycastle.crypto.InvalidCipherTextException
-dontwarn org.bouncycastle.crypto.engines.AESEngine
-dontwarn org.bouncycastle.crypto.modes.GCMBlockCipher
-dontwarn org.bouncycastle.crypto.params.AEADParameters
-dontwarn org.bouncycastle.crypto.params.KeyParameter
-dontwarn org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider
-dontwarn org.bouncycastle.jce.provider.BouncyCastleProvider
-dontwarn org.bouncycastle.openssl.PEMKeyPair
-dontwarn org.bouncycastle.openssl.PEMParser
-dontwarn org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter

-dontwarn org.conscrypt.Conscrypt$Version
-dontwarn org.conscrypt.Conscrypt
-dontwarn org.conscrypt.ConscryptHostnameVerifier

-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.net.ssl.OpenJSSE
-dontwarn org.openjsse.net.ssl.OpenJSSE

-dontwarn com.google.crypto.tink.subtle.Ed25519Sign$KeyPair
-dontwarn com.google.crypto.tink.subtle.Ed25519Sign
-dontwarn com.google.crypto.tink.subtle.Ed25519Verify
-dontwarn com.google.crypto.tink.subtle.X25519
-dontwarn edu.umd.cs.findbugs.annotations.NonNull
-dontwarn edu.umd.cs.findbugs.annotations.Nullable
-dontwarn edu.umd.cs.findbugs.annotations.SuppressFBWarnings

-dontwarn com.segment.analytics.kotlin.core.platform.plugins.logger.LogFilterKind
-dontwarn com.segment.analytics.kotlin.core.platform.plugins.logger.LogTargetKt
2 changes: 1 addition & 1 deletion auth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ android {
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', '../shared-proguard-rules.pro'
}
}
compileOptions {
Expand Down
24 changes: 24 additions & 0 deletions auth/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,27 @@
-keep class androidx.credentials.playservices.** {
*;
}

-keep interface org.openedx.auth.presentation.AuthRouter { public *; }
-keep interface org.openedx.auth.presentation.AuthAnalytics { public *; }
-keep class org.openedx.auth.presentation.AgreementProvider { public *; }
-keep class org.openedx.auth.presentation.sso.** { public *; }

-keep interface org.openedx.auth.data.api.AuthApi { public *; }
-keep class org.openedx.auth.data.api.AuthApi$DefaultImpls { public *; }

-keep class org.openedx.auth.data.repository.AuthRepository { public *; }
-keep class org.openedx.auth.domain.interactor.AuthInteractor { public *; }

-keep class org.openedx.auth.presentation.logistration.LogistrationViewModel { public *; }
-keep class org.openedx.auth.presentation.restore.RestorePasswordViewModel { public *; }
-keep class org.openedx.auth.presentation.signin.SignInViewModel { public *; }
-keep class org.openedx.auth.presentation.signup.SignUpViewModel { public *; }

-keep class org.openedx.auth.presentation.logistration.LogistrationFragment { public *; }
-keep class org.openedx.auth.presentation.signin.SignInFragment$Companion { public *; }
-keep class org.openedx.auth.presentation.signin.SignInFragment { public *; }

-keep class org.openedx.auth.presentation.restore.RestorePasswordFragment { public *; }
-keep class org.openedx.auth.presentation.signup.SignUpFragment$Companion { public *; }
-keep class org.openedx.auth.presentation.signup.SignUpFragment { public *; }
2 changes: 1 addition & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ android {
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', '../shared-proguard-rules.pro'
}
}
compileOptions {
Expand Down
49 changes: 48 additions & 1 deletion core/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,51 @@
# hide the original source file name.
#-renamesourcefileattribute SourceFile

-dontwarn java.lang.invoke.StringConcatFactory
-dontwarn java.lang.invoke.StringConcatFactory

-keep class org.openedx.core.config.** {
<fields>;
<methods>;
}
-keep class org.openedx.core.system.ResourceManager { *; }
-keep class org.openedx.core.ImageProcessor { *; }
-keep interface org.openedx.core.presentation.global.app_upgrade.AppUpgradeRouter { *; }
-keep class org.openedx.core.module.download.FileDownloader { *; }
-keep class org.openedx.core.module.DownloadWorkerController { *; }
-keep class org.openedx.core.presentation.global.AppData { *; }
-keep class org.openedx.core.presentation.dialog.appreview.AppReviewManager { *; }
-keep class org.openedx.core.module.TranscriptManager
-keep class org.openedx.core.module.billing.BillingProcessor
-keep class org.openedx.core.presentation.global.WhatsNewGlobalManager
-keep interface org.openedx.core.presentation.dialog.appreview.AppReviewAnalytics
-keep interface org.openedx.core.presentation.CoreAnalytics
-keep interface org.openedx.core.presentation.IAPAnalytics
-keep class org.openedx.core.utils.FileUtil { public *; }
-keep interface org.openedx.core.presentation.dialog.appreview.AppReviewAnalytics

-keep interface org.openedx.core.data.api.CookiesApi
-keep interface org.openedx.core.data.api.CourseApi
-keep class org.openedx.core.data.api.CourseApi$DefaultImpls { *; }
-keep interface org.openedx.core.data.api.iap.InAppPurchasesApi
-keep class org.openedx.core.Validator

-keep class org.openedx.core.presentation.dialog.selectorbottomsheet.SelectDialogViewModel
-keep class org.openedx.core.presentation.iap.IAPViewModel
-keep class org.openedx.core.presentation.settings.video.VideoQualityViewModel
-keep class org.openedx.core.module.download.BaseDownloadViewModel

-keep class org.openedx.core.data.repository.iap.IAPRepository
-keep class org.openedx.core.domain.interactor.IAPInteractor
-keep interface org.openedx.core.presentation.global.InsetHolder { public *;}
-keep interface org.openedx.core.presentation.global.WindowSizeHolder
-keep class org.openedx.core.utils.Logger { public *; }
-keep class org.openedx.core.utils.TimeUtils { *; }
-keep class org.openedx.core.SingleEventLiveData { *; }
-keep class org.openedx.core.extension.** { static public *;}

-keep class org.openedx.core.ui.** { public *;}

-keep class org.openedx.core.exception.iap.* { public *;}
-keep class org.openedx.core.presentation.IAPAnalytics** { public *;}

-keep class org.openedx.core.UIMessage** { public *;}
2 changes: 1 addition & 1 deletion course/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android {
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', '../shared-proguard-rules.pro'
}
}
compileOptions {
Expand Down
22 changes: 21 additions & 1 deletion course/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,24 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

-keep interface org.openedx.course.presentation.CourseRouter
-keep interface org.openedx.course.presentation.CourseAnalytics

-keep class org.openedx.course.presentation.unit.container.CourseUnitContainerViewModel
-keep class org.openedx.course.presentation.unit.html.HtmlUnitViewModel
-keep class org.openedx.course.presentation.unit.video.BaseVideoViewModel
-keep class org.openedx.course.presentation.unit.video.EncodedVideoUnitViewModel
-keep class org.openedx.course.presentation.unit.video.VideoUnitViewModel
-keep class org.openedx.course.presentation.unit.video.VideoViewModel
-keep class org.openedx.course.presentation.videos.CourseVideoViewModel
-keep class org.openedx.course.settings.download.DownloadQueueViewModel

-keep class org.openedx.course.data.repository.CourseRepository
-keep class org.openedx.course.domain.interactor.CourseInteractor
-keep class org.openedx.course.presentation.container.CourseContainerViewModel
-keep class org.openedx.course.presentation.dates.CourseDatesViewModel
-keep class org.openedx.course.presentation.handouts.HandoutsViewModel
-keep class org.openedx.course.presentation.outline.CourseOutlineViewModel
-keep class org.openedx.course.presentation.section.CourseSectionViewModel
2 changes: 1 addition & 1 deletion dashboard/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android {
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', '../shared-proguard-rules.pro'
}
}

Expand Down
11 changes: 10 additions & 1 deletion dashboard/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

-keep interface org.openedx.dashboard.presentation.DashboardRouter
-keep interface org.openedx.dashboard.presentation.DashboardAnalytics
-keep class org.openedx.dashboard.data.repository.DashboardRepository { *; }
-keep class org.openedx.dashboard.domain.interactor.DashboardInteractor { *; }
-keep class org.openedx.dashboard.presentation.DashboardListViewModel { *; }
-keep class org.openedx.courses.presentation.DashboardGalleryViewModel { *; }
-keep class org.openedx.courses.presentation.AllEnrolledCoursesViewModel
-keep class org.openedx.learn.presentation.LearnViewModel
2 changes: 1 addition & 1 deletion discovery/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', '../shared-proguard-rules.pro'
}
}

Expand Down
17 changes: 16 additions & 1 deletion discovery/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,19 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

-keep interface org.openedx.discovery.presentation.DiscoveryRouter
-keep interface org.openedx.discovery.presentation.DiscoveryAnalytics
-keep interface org.openedx.discovery.data.api.DiscoveryApi
-keep class org.openedx.discovery.data.repository.DiscoveryRepository
-keep class org.openedx.discovery.domain.interactor.DiscoveryInteractor
-keep class org.openedx.discovery.presentation.NativeDiscoveryViewModel
-keep class org.openedx.discovery.presentation.WebViewDiscoveryViewModel

-keep class org.openedx.discovery.presentation.detail.CourseDetailsViewModel
-keep class org.openedx.discovery.presentation.info.CourseInfoViewModel
-keep class org.openedx.discovery.presentation.program.ProgramViewModel
-keep class org.openedx.discovery.presentation.search.CourseSearchViewModel
-keep class org.openedx.discovery.data.converter.DiscoveryConverter

2 changes: 1 addition & 1 deletion discussion/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android {
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', '../shared-proguard-rules.pro'
}
}
compileOptions {
Expand Down
16 changes: 15 additions & 1 deletion discussion/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,18 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

-keep interface org.openedx.discussion.presentation.DiscussionRouter
-keep interface org.openedx.discussion.presentation.DiscussionAnalytics
-keep interface org.openedx.discussion.data.api.DiscussionApi

-keep class org.openedx.discussion.data.repository.DiscussionRepository
-keep class org.openedx.discussion.domain.interactor.DiscussionInteractor

-keep class org.openedx.discussion.presentation.comments.DiscussionCommentsViewModel
-keep class org.openedx.discussion.presentation.responses.DiscussionResponsesViewModel
-keep class org.openedx.discussion.presentation.search.DiscussionSearchThreadViewModel
-keep class org.openedx.discussion.presentation.threads.DiscussionAddThreadViewModel
-keep class org.openedx.discussion.presentation.threads.DiscussionThreadsViewModel
-keep class org.openedx.discussion.presentation.topics.DiscussionTopicsViewModel
2 changes: 1 addition & 1 deletion profile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android {
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', '../shared-proguard-rules.pro'
}
}

Expand Down
16 changes: 15 additions & 1 deletion profile/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,18 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

-keep interface org.openedx.profile.presentation.ProfileRouter { public *;}
-keep interface org.openedx.profile.presentation.ProfileAnalytics { public *;}
-keep interface org.openedx.profile.data.api.ProfileApi { public *;}
-keep class org.openedx.profile.data.repository.ProfileRepository { public *;}
-keep class org.openedx.profile.domain.interactor.ProfileInteractor { public *;}
-keep class org.openedx.profile.presentation.anothersaccount.AnothersProfileViewModel { public *;}
-keep class org.openedx.profile.presentation.profile.ProfileViewModel { public *;}
-keep class org.openedx.profile.presentation.edit.EditProfileViewModel { public *;}
-keep class org.openedx.profile.presentation.manageaccount.ManageAccountViewModel { public *;}
-keep class org.openedx.profile.presentation.settings.SettingsViewModel { public *;}
-keep class org.openedx.profile.presentation.video.VideoSettingsViewModel { public *;}
-keep class org.openedx.profile.presentation.calendar.CalendarViewModel { public *;}
-keep class org.openedx.profile.presentation.delete.DeleteProfileViewModel { public *;}
Loading

0 comments on commit 1cfb1f8

Please sign in to comment.