Got AssertionError: No such enum entry LIBRARY_GROUP_PREFIX after upgrading to Android Studio 4.2 and Gradle 6.7.1 plugin 4.2.0

Viewed 1733

After upgrading to Android Studio 4.2 and Gradle to Gradle 6.7.1 plugin 4.2.0 we've got following build error but studio don't highlight any errors in the code. What can be wrong? Project uses Kotlin and databindings.

e: java.lang.AssertionError: No such enum entry LIBRARY_GROUP_PREFIX in org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl@b254b575
        at org.jetbrains.kotlin.ir.util.ConstantValueGenerator.generateConstantOrAnnotationValueAsExpression(ConstantValueGenerator.kt:89)
        at org.jetbrains.kotlin.ir.util.ConstantValueGenerator.generateConstantOrAnnotationValueAsExpression(ConstantValueGenerator.kt:81)
        at org.jetbrains.kotlin.ir.util.ConstantValueGenerator.generateAnnotationConstructorCall(ConstantValueGenerator.kt:163)
        at org.jetbrains.kotlin.psi2ir.generators.AnnotationGenerator.generateAnnotationsForDeclaration(AnnotationGenerator.kt:47)
        at org.jetbrains.kotlin.psi2ir.generators.AnnotationGenerator.visitDeclaration(AnnotationGenerator.kt:25)
        at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitFunction(IrElementVisitorVoid.kt:49)
        at org.jetbrains.kotlin.psi2ir.generators.AnnotationGenerator.visitFunction(AnnotationGenerator.kt:13)
        at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitSimpleFunction(IrElementVisitorVoid.kt:52)
        at org.jetbrains.kotlin.psi2ir.generators.AnnotationGenerator.visitSimpleFunction(AnnotationGenerator.kt:13)
        at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitSimpleFunction(IrElementVisitorVoid.kt:53)
        at org.jetbrains.kotlin.psi2ir.generators.AnnotationGenerator.visitSimpleFunction(AnnotationGenerator.kt:13)
        at org.jetbrains.kotlin.psi2ir.generators.AnnotationGenerator.visitSimpleFunction(AnnotationGenerator.kt:13)
        at org.jetbrains.kotlin.ir.declarations.IrSimpleFunction.accept(IrSimpleFunction.kt:29)
        at org.jetbrains.kotlin.ir.declarations.IrClass.acceptChildren(IrClass.kt:61)

If run build again with --info option we've got errors for databinding for our custom views like:

  public final TileFrameLayout viewShortTileWithPxp;
               ^
  symbol:   class TileFrameLayout
  location: class FavoriteTileWithPxpBinding.java:34: error: cannot find symbol
  protected TileModeField mTileMode;

At the same time generated FavoriteTileWithPxpBinding.java has proper import for TileFrameLayout and Studio correctly show all dependencies.

All this worked before upgrade.

4 Answers

if you have an error that is No such enum entry LIBRARY_GROUP_PREFIX. you should do implementation "androidx.annotation:annotation:1.1.0" to the module which error.

en..., I found if the only app is ok but if the app has other modules,it will have error like

'Task :life_module:compileDebugKotlin FAILED
e: java.lang.AssertionError: No such enum entry LIBRARY_GROUP_PREFIX in org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl@b254b575'

Problem solved. There were several changes:

  1. Updating support libraries to AndroidX
  2. Updating versions of some other libs like Dagger
  3. Updating Kotlin

And yes, Invalidate caches & Restart after all of these.

Downgrading Kotlin from 1.5.31 to 1.4.20 fixed this for me.

In my case, I migrated to Gradle 7.2. But as legacy, in the app level of Gradle, was this:

configurations.all {
   resolutionStrategy.force 'com.android.support:support-annotations:24.2.0'
}

It forced to use the version 1.0.0 of the 'androidx.annotation:annotation' lib, even if I obviously used the 'annotation' dependency with mentioning any other versions. The thing is that in this '1.0.0' version, there is no 'LIBRARY_GROUP_PREFIX' enum item. After I have deleted the 'resolutionStrategy.force' block, all began to work.

Related