Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in
Asked Answered
B

1

6

hello guys i am currently develop android app, i have the intention to use proguard to protecting my app from reverse engineering

however, after i applied proguard to my app was an error like this :

Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in mypath\app\build\outputs\mapping\debug\missing_rules.txt.

Missing class sun.security.x509.X509CertInfo (referenced from: java.lang.String org.openjsse.sun.security.ssl.SSLLogger$SSLSimpleFormatter.formatCertificate(java.security.cert.Certificate))

Missing class sun.util.logging.PlatformLogger$Level (referenced from: void org.openjsse.sun.net.www.protocol.https.HttpsClient.<init>(javax.net.ssl.SSLSocketFactory, java.net.URL, java.net.Proxy, int) and 1 other context)

Missing class sun.util.logging.PlatformLogger (referenced from: void org.openjsse.sun.net.www.protocol.https.HttpsClient.<init>(javax.net.ssl.SSLSocketFactory, java.net.URL, java.net.Proxy, int) and 1 other context)

i have try to set up the missing_rules to fix this problem, but it didn't work at all can you guys help me to find the solution of this problem ?

here is my code :

// Proguard-rule (module app)


# Keep file R and Manifest
-keep class **.R
-keep class **.R$* {*;}
-keep class **.BuildConfig {*;}
-keep class **.Manifest {*;}

# Keep Dependency Injection Framework related classes and methods
-keep class dagger.hilt.** { *; }
-keep class javax.inject.** { *; }
-keep class javax.annotation.** { *; }

# Keep Model and Repository Classes
-keep class com.example.core.data.model.** { *; }
-keep class com.example.core.data.repo.** { *; }

# Keep ViewModels
-keep class * extends androidx.lifecycle.ViewModel

# Keep Parcelable Classes
-keep class * implements android.os.Parcelable {
    public static final android.os.Parcelable$Creator *;
}

# Keep UI-related classes
-keep class com.example.ui.activity.** { *; }
-keep class com.example.ui.fragment.** { *; }
-keep class com.example.service.** { *; }

# Keeping all classes in a particular package
-keep class com.example.package.** { *; }

# Maintains all classes mentioned in a particular file
#-keep @com.example.rules.txt

# Maintain parcelable classes
-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

# Maintain model classes
-keep class com.example.model.** { *; }

# Maintain class of service
-keep class com.example.service.** { *; }

# Maintain classes required for SSL/TLS handling
-keep class okhttp3.internal.platform.ConscryptPlatform {*;}
-keep class okhttp3.internal.platform.OpenJSSEPlatform {*;}
-keep class org.bouncycastle.** {*;}
-keep class org.conscrypt.** {*;}
-keep class org.openjsse.** {*;}

# Maintain parcelable classes
-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

# Keep classes required by OpenJSSE
-keep class sun.security.x509.** { *; }
-keep class sun.util.logging.** { *; }

// consumer-rules (core module)

##---------------Begin: proguard configuration for SQLCipher  ----------
-keep,includedescriptorclasses class net.sqlcipher.** { *; }
-keep,includedescriptorclasses interface net.sqlcipher.** { *; }


##---------------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 com.google.gson.examples.android.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>;
}


##---------------Begin: proguard configuration for 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

# 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>

-dontwarn kotlinx.**


##---------------Begin: proguard configuration for Glide ----------
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
**[] $VALUES;
public *;
}

# Uncomment for DexGuard only
#-keepresourcexmlelements manifest/application/meta-data@value=GlideModule


##---------------Begin: proguard configuration for RxJava ----------
# Uncomment if you use RxJava
#-dontwarn java.util.concurrent.Flow*

# Keep file R and Manifest
-keep class **.R
-keep class **.R$* {*;}
-keep class **.BuildConfig {*;}
-keep class **.Manifest {*;}

# Keep Dependency Injection Framework related classes and methods
-keep class dagger.hilt.** { *; }
-keep class javax.inject.** { *; }
-keep class javax.annotation.** { *; }

# Keep Model and Repository Classes
-keep class com.example.core.data.model.** { *; }
-keep class com.example.core.data.repo.** { *; }

# Keep ViewModels
-keep class * extends androidx.lifecycle.ViewModel

# Keep Parcelable Classes
-keep class * implements android.os.Parcelable {
    public static final android.os.Parcelable$Creator *;
}

# Keep UI-related classes
-keep class com.example.core.ui.activity.** { *; }
-keep class com.example.core.ui.fragment.** { *; }
-keep class com.example.core.service.** { *; }


# Keeping all classes in a particular package
-keep class com.example.package.** { *; }

# Maintains all classes mentioned in a particular file
#-keep @com.example.rules.txt

# keep model class
-keep class com.example.model.** { *; }

# Menjaga kelas service
-keep class com.example.service.** { *; }

# Menjaga kelas-kelas yang diperlukan untuk penanganan  SSL/TLS
-keep class okhttp3.internal.platform.ConscryptPlatform {*;}
-keep class okhttp3.internal.platform.OpenJSSEPlatform {*;}
-keep class org.bouncycastle.** {*;}
-keep class org.conscrypt.** {*;}
-keep class org.openjsse.** {*;}


# Keep classes required by OpenJSSE
-keep class sun.security.x509.** { *; }
-keep class sun.util.logging.** { *; }

// missing_rules.txt

# Please add these rules to your existing keep rules in order to suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn com.android.org.conscrypt.SSLParametersImpl
-dontwarn javax.naming.Binding
-dontwarn javax.naming.NamingEnumeration
-dontwarn javax.naming.NamingException
-dontwarn javax.naming.directory.Attribute
-dontwarn javax.naming.directory.Attributes
-dontwarn javax.naming.directory.DirContext
-dontwarn javax.naming.directory.InitialDirContext
-dontwarn javax.naming.directory.SearchControls
-dontwarn javax.naming.directory.SearchResult
-dontwarn org.apache.harmony.xnet.provider.jsse.SSLParametersImpl
-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
-dontwarn sun.net.util.IPAddressUtil
-dontwarn sun.net.www.http.HttpClient
-dontwarn sun.net.www.http.KeepAliveCache
-dontwarn sun.net.www.protocol.http.Handler
-dontwarn sun.net.www.protocol.http.HttpURLConnection$TunnelState
-dontwarn sun.net.www.protocol.http.HttpURLConnection
-dontwarn sun.net.www.protocol.https.Handler
-dontwarn sun.security.action.GetBooleanAction
-dontwarn sun.security.action.GetIntegerAction
-dontwarn sun.security.action.GetLongAction
-dontwarn sun.security.action.GetPropertyAction
-dontwarn sun.security.action.OpenFileInputStreamAction
-dontwarn sun.security.internal.interfaces.TlsMasterSecret
-dontwarn sun.security.internal.spec.TlsKeyMaterialParameterSpec
-dontwarn sun.security.internal.spec.TlsKeyMaterialSpec
-dontwarn sun.security.internal.spec.TlsPrfParameterSpec
-dontwarn sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec
-dontwarn sun.security.jca.ProviderList
-dontwarn sun.security.jca.Providers
-dontwarn sun.security.provider.certpath.AlgorithmChecker
-dontwarn sun.security.provider.certpath.CertId
-dontwarn sun.security.provider.certpath.OCSP
-dontwarn sun.security.provider.certpath.OCSPResponse$ResponseStatus
-dontwarn sun.security.provider.certpath.OCSPResponse$SingleResponse
-dontwarn sun.security.provider.certpath.OCSPResponse
-dontwarn sun.security.provider.certpath.PKIXExtendedParameters
-dontwarn sun.security.provider.certpath.ResponderId
-dontwarn sun.security.provider.certpath.UntrustedChecker
-dontwarn sun.security.util.AlgorithmDecomposer
-dontwarn sun.security.util.AnchorCertificates
-dontwarn sun.security.util.BitArray
-dontwarn sun.security.util.Debug
-dontwarn sun.security.util.DerInputStream
-dontwarn sun.security.util.DerOutputStream
-dontwarn sun.security.util.DerValue
-dontwarn sun.security.util.DisabledAlgorithmConstraints
-dontwarn sun.security.util.ECUtil
-dontwarn sun.security.util.HostnameChecker
-dontwarn sun.security.util.KeyUtil
-dontwarn sun.security.util.LegacyAlgorithmConstraints
-dontwarn sun.security.util.ObjectIdentifier
-dontwarn sun.security.util.SafeDHParameterSpec
-dontwarn sun.security.util.SignatureUtil
-dontwarn sun.security.util.math.ImmutableIntegerModuloP
-dontwarn sun.security.util.math.IntegerFieldModuloP
-dontwarn sun.security.util.math.IntegerModuloP
-dontwarn sun.security.util.math.MutableIntegerModuloP
-dontwarn sun.security.util.math.intpoly.IntegerPolynomial1305
-dontwarn sun.security.validator.ValidatorException
-dontwarn sun.security.x509.CertificateExtensions
-dontwarn sun.security.x509.Extension
-dontwarn sun.security.x509.KeyIdentifier
-dontwarn sun.security.x509.NetscapeCertTypeExtension
-dontwarn sun.security.x509.PKIXExtensions
-dontwarn sun.security.x509.SerialNumber
-dontwarn sun.security.x509.X500Name
-dontwarn sun.security.x509.X509CertImpl
-dontwarn sun.security.x509.X509CertInfo
-dontwarn sun.util.logging.PlatformLogger$Level
-dontwarn sun.util.logging.PlatformLogger
Briney answered 5/3, 2024 at 7:42 Comment(0)
H
-2

I got the same problem when i set minifyEnabled value to true.

        release {
        debuggable false
        minifyEnabled true // change it
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }

hope it will solve your problem

Hydrobomb answered 27/5, 2024 at 16:26 Comment(3)
i intended to make it true for using the proguard, but thanks for answering ;), i've also solved the problem months agoBriney
@Dzy, do you care to mention how you solved it? This is what StackOverflow is here for.Schizogony
sure, you can visit this link : issuetracker.google.com/issues/330437902 if you still have a problem, you can try to ask to issuetracker, it's worth to tryBriney

© 2022 - 2025 — McMap. All rights reserved.