I'm trying to add Jetpack Compose to my project, but after making all changes to my build.gradle
file I'm not able to build it. And the reason is having anonymous classes in the project.
Instead of describing my project, build.gradle
file and all changes I made, I used the android-compose-codelabs project as a sandbox.
So basically, I clone the BasicsCodelab project and can successfully build it, but after adding this block at the end of onCreate
method (MainActivity.kt
):
val listener = object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String): Boolean {
return false
}
override fun onQueryTextChange(newText: String): Boolean {
return true
}
}
SearchView(this).setOnQueryTextListener(listener)
and clearing the project I'm unable to build it anymore. So, adding an anonymous class to your project (with Jetpack Compose) leads to build failure.
Error:
LiveLiterals$MainActivityKt.class
com.android.tools.r8.errors.b: Space characters in SimpleName
'Boolean$fun-onQueryTextSubmit$class-$no name provided$$val-listener$fun-onCreate$class-MainActivity'
are not allowed prior to DEX version 040
I assume the no name provided
part is the reason (should be no-name-provided
?) but I'm not that familiar with building pipeline to figure out the problem. I tried to disable R8 but no result.