https://kotlinlang.org logo
t

Timo Drick

08/26/2020, 10:55 PM
When updateing to Android Studio 4.2 canary 8 and gradle build tools 4.2.0-alpha8 i get following compiler error:
LiveLiterals$ComposeWidgetsKt.class: D8: com.android.tools.r8.errors.b: Space characters in SimpleName 'Int$arg-0$call-layout$branch$if$fun-measure$class-$no name provided$$arg-0$call-then$fun-visibility' are not allowed prior to DEX version 040
Compiling with
classpath 'com.android.tools.build:gradle:4.2.0-alpha07'
works fine. also upgraded to gradle 6.6-rc-6
r

romainguy

08/26/2020, 11:00 PM
That bug was reported on another Slack channel, @Leland Richardson [G] can give more info
l

Leland Richardson [G]

08/26/2020, 11:03 PM
eh. this bug is freaking me out a bit. So the root cause of the bug is from the compose compiler treating an anonymous class incorrectly because its name has a space in it. It’s a simple bug and should be fixed soon. BUT, the bigger issue is that this is a bug from code that shouldn’t get run except for in the Preview tool in studio. Can you clarify: 1. this bug is happening in a normal gradle build from command line? 2. if yes, does it persist when you blow away your gradle cache?
t

Timo Drick

08/26/2020, 11:39 PM
1. yes it happens also on command line 2. it perists when i am deleting the .gradle project folder and also deleting the ~/.gradle/caches folder It only fails in my little bit more complex projects not in a simple hello world sample
l

Leland Richardson [G]

08/26/2020, 11:40 PM
well the error message can show you the root cause and you can get around the exception (looks like there is a top level
visibility
function which calls
then
which passes in an anonymous class as the first argument. If you change this to a named-class the error will go away
but if you can not do that first and help me diagnose why this code is running in the first place, i would be very grateful 🙂
can you try adding this to your gradle file?
Copy code
kotlinOptions.freeCompilerArgs += ['-P', 'plugin:androidx.compose.plugins.idea:liveLiterals=true']
or actually, “false” is what we want here
Copy code
kotlinOptions.freeCompilerArgs += ['-P', 'plugin:androidx.compose.plugins.idea:liveLiterals=false']
i wonder if that fixes it
t

Timo Drick

08/26/2020, 11:43 PM
added it but does not helped
l

Leland Richardson [G]

08/26/2020, 11:44 PM
with false or true?
t

Timo Drick

08/26/2020, 11:44 PM
Both
l

Leland Richardson [G]

08/26/2020, 11:48 PM
hmm. i’m not sure the flag is correct then
maybe
Copy code
kotlinOptions.freeCompilerArgs += ['-Pplugin:androidx.compose.plugins.idea:liveLiterals=false']
if that doesn’t work, i’ll stop trying to get you to try stuff and just work on reproducing myself, sorry
you should be able to fix it by changing the anonymous class to a named one
t

Timo Drick

08/26/2020, 11:50 PM
But i was able to solve the problem by following your description
l

Leland Richardson [G]

08/26/2020, 11:50 PM
(there is nothing wrong with your code, it is a bug in the compose compiler)
t

Timo Drick

08/26/2020, 11:50 PM
tried the Ppluginandroidx.compose.plugins.idealiveLiterals=false' but did not solved the problem
l

Leland Richardson [G]

08/26/2020, 11:51 PM
but the code that is causing it shouldn’t be running in the first place
t

Timo Drick

08/26/2020, 11:53 PM
I do not have any compose previews in my code. And also removed the androidx.ui:ui-tooling dependency but the problem is still there
l

Leland Richardson [G]

08/26/2020, 11:54 PM
yeah its a different code generation pathway
but not supposed to be on by default
i fear this may be a bug with AGP
t

Timo Drick

08/26/2020, 11:55 PM
@Leland Richardson [G] thank you for your fast response. So at least i am able to use canary 8 now 😄
l

Leland Richardson [G]

08/26/2020, 11:55 PM
no problem
fair warning though: if this codegen is running, the resulting compose code will not be as efficient as it should be. so please don’t go posting any “compose is slow” blog posts in the mean time if you don’t mind 😱
t

Timo Drick

08/26/2020, 11:57 PM
oh i just saw that i tested the compiler options on the wrong module. Please let me rerun the tests. Just a second
l

Leland Richardson [G]

08/26/2020, 11:59 PM
that would be great, thanks!
t

Timo Drick

08/27/2020, 12:02 AM
No sorry set the options on every module. The problem code is inside of a library module. And the library itself compiles fine. Just when i use the library in an app module the app module will not compile
l

Leland Richardson [G]

08/27/2020, 12:03 AM
yeah the bug itself is happening in the dex phase, so you will only see it when you build the app
but that flag (though the format of these flags always elude me so i might just be off by a character somewhere) was supposed to turn this off. but AGP could be re-setting it in a way that it’s not able to be turned off 😕
t

Timo Drick

08/27/2020, 12:08 AM
Btw. i am working now for several month with compose and i was able to measure an increase in performance in my custom LazyColumn implementations. Now the release builds are near to the performance of legacy android recyclerview lists. (I do tests with many images also loading images in background during fast scrolling throw the list) Showing the HWUI rendering Bars now constantly under the green line (most of the time just half the way to green)
l

Leland Richardson [G]

08/27/2020, 12:11 AM
ah cool. good to hear. are your lazycolumn implementations OSS?
t

Timo Drick

08/27/2020, 12:20 AM
What do you mean with OSS? I just started a custom one before AdapterList worked well. I think now the official LazyColumn implementation is stable but still misses some features. My implementation works a little bit different than the official one. It just uses Layout and dynamically changing the child views that are rendered. But performance wise it is very close to the LazyColumn implementation. https://gitlab.com/timod/compose-playground/-/blob/master/compose_list/src/main/java/de/drick/compose/list/LayoutList.kt
👍 1
l

Leland Richardson [G]

08/27/2020, 3:14 PM
This is excellent! Thanks for sharing. Indeed LazyColumn is missing a lot of features / use cases still while we nail down the API. It makes me really happy to see folks like you diving in and making your own though! Very cool. Do you mind if I point people to this from time to time? BTW, by “OSS” i mean “is it open source” which could mean a few things i guess, but I was mostly curious if you were planning on publishing it as a 3rd party library alternative to LazyColumn (which I think would be great, just to be clear).
t

Timo Drick

08/27/2020, 3:19 PM
Of course i would be happy if you point out my implementation. But it is also under heavy development and also misses features 🙂 (Just solved some things i need) Currently i am playing around getting flows working as input. For this i need a feedback when the end of list is reached.
I am planning to release this also as a library.
5 Views