I'm consuming a Java library that contains numerous classes and a few enums. I am using this library in an Android project in Android Studio. The classes work just fine, but Android Studio does not recognize the enums. I can't import them or use them in Java or Kotlin files. I've used these enums in a pure Java project in IntelliJ before.
When I look at the "External Dependencies" in Android Studio and find this library, the classes show as just the class name (e.g. MyClass), but these enums include .class (e.g. MyEnum.class). Not sure if that's a clue. When I click in, I see the enum file contents just fine.
Some of my Android project settings:
Update
I found INFO level log messages corresponding to these enum classes in the Android Studio logs.
I obfuscated the package name, but this is the error I'm seeing:
INFO - #c.i.p.i.c.ClassFileStubBuilder - /Users/justin/.gradle/caches/modules-2/files-2.1/com.group/library-name/1.0.2/c5afbe59580f0678d1133deafc1d3d786e039b4b/library-name-1.0.2.jar!/com/group/library-name/FlagValueType.class: /Users/justin/.gradle/caches/modules-2/files-2.1/com.group/library-name/1.0.2/c5afbe59580f0678d1133deafc1d3d786e039b4b/library-name-1.0.2.jar!/com/group/FlagValueType.class: Cannot invoke "String.length()" because "text" is null
The error at the end is:
Cannot invoke "String.length()" because "text" is null
This error must be preventing Android Studio from parsing this file correctly.
This ended up being a bug in Android Studio. Upgrading to the current release candidate resolved the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With