Error about "com.android.tools.r8.errors.b: A member class cannot also be a (non-member) local class at the same time."

Viewed 1880

I am running a gradle-based sample .apk code in Android studio and I face this error:

com.android.tools.r8.errors.b: A member class cannot also be a (non-member) local class at the same time.
This is likely due to invalid EnclosingMethod and InnerClasses attributes:
[enclosingClass: Lcom/androidplot/xy/XYLegendWidget;, enclosingMethod: null]
[access : 2, inner: Lcom/androidplot/Plot$BufferedCanvas;, outer: Lcom/androidplot/Plot;, innerName: BufferedCanvas]

It is related to the implementation files('libs/androidplot-core-0.6.1-SNAPSHOT.jar') in the build.gradle dependencies. Any ideas?

1 Answers

This looks like an issue with the library. The content of the InnerClasses and EnclosingMethod attributes is described in The Java® Virtual Machine Specification sections 4.7.6. The InnerClasses Attribute and 4.7.7. The EnclosingMethod Attribute. There is basically says that EnclosingMethod can only be present if and only if it represents a local class or an anonymous class and for a local class or an anonymous class the outer part of InnerClasses attribute must be null for that class. These properties are violated here.

As far as I can see there are many more recent version of the androidplot-core library available: https://mvnrepository.com/artifact/com.androidplot/androidplot-core. Please try a more recent one to see if that doesn't solve the problem.

Related