Home > Back-end >  com.android.tools.r8.CompilationFailedException:Compilation failed to complete, position:Lcom/facebo
com.android.tools.r8.CompilationFailedException:Compilation failed to complete, position:Lcom/facebo

Time:03-30

I have some error, after updated kotlin version (ext.kotlin_version) to 1.6.10:

com.android.tools.r8.internal.E00: Unexpected type in conversion to primitive: OBJECT

Execution failed for task ':app:minifyReleaseWithR8'.
> com.android.tools.r8.CompilationFailedException: Compilation failed to complete, position: Lcom/facebook/login/DefaultAudience$EnumUnboxingLocalUtility;getNativeProtocolAudience(I)Ljava/lang/String;, origin: ..\.gradle\caches\transforms-3\57102c4e3d32396b86898e5ca0dd620d\transformed\jetified-facebook-core-7.1.0-runtime.jar:com/facebook/login/DefaultAudience.class

It happened, if I use options minifyEnabled true in my build.gradle(:app) with Generate signed bundle. If I use old ext.kotlin_version (for examle, 1.5.0) this error did not appear.

I think, if I use correct rule(s) in proguard-rules.pro I could resolve this issue.

CodePudding user response:

I find right rule for decide this problem. You need add this code into proguard-rules.pro:

-keep class com.facebook.login.** {*;}

This line let ignore option minifyEnabled true for all files into com.facebook.login package.

CodePudding user response:

This was caused by an issue in R8. Fix is available in R8 3.1.67, 3.2.50 and will soon be in a 3.3.x-dev version.

Add the following to settings.gradle or settings.gradle.kts to use a specific version of R8 different from the one bundeled with AGP:

pluginManagement {
    buildscript {
        repositories {
            mavenCentral()
            maven {
                url = uri("https://storage.googleapis.com/r8-releases/raw")
            }
        }
        dependencies {
            classpath("com.android.tools:r8:X.Y.Z")
            classpath('com.google.guava:guava:30.1.1-jre')  // <-- THIS IS REQUIRED UNTIL R8 3.2.4-dev
        }
    }
}
  • Related