I’m getting the error message above when trying to use Layout inspector on my Project when I’m using Android Studio Giraffe | 2022.3.1 Canary 6.
I also tried it with Android Studio Electric Eel | 2022.1.1 Patch 1. There I only get the error message: Compose inspection is not available.
For version Control I’m using chris banes’s BOM
composeOptions {
kotlinCompilerExtensionVersion '1.4.0'
}
dependencies{
androidx.compose = 2023.02.00-alpha02
..
implementation platform("dev.chrisbanes.compose:compose-bom:${androidx.compose}")
androidTestImplementation platform("dev.chrisbanes.compose:compose-bom:${androidx.compose}")
implementation "androidx.compose.ui:ui"
implementation "androidx.compose.ui:ui-util"
implementation "androidx.compose.material:material"
implementation "androidx.compose.material:material-icons-extended"
implementation "androidx.compose.ui:ui-tooling"
debugImplementation "androidx.compose.ui:ui-tooling"
implementation "androidx.compose.ui:ui-tooling-preview"
I also tried to use own verrsions without using the BOM but that gave me the same issue.
Invalidating Cache and Rebuilding Project also didn’t work.
Has anybody an idea how I can fix this and start using my Layout inspector again?
4
Answers
Thanks to CodePoet and VangelNum both of them helped me significantly.
After some trying out with the versions they suggested I found out the following:
I need to use
And change the version of ui:ui to
Here you need to be careful as I tried several times with "..." and it didn't work. You need to use '...' that it takes the written version.
Like this it works for me.
Update: just using
Also does the trick.
You may want to try updating to the latest version to see if that helps:
The current
kotlinCompilerExtensionVersion
is1.4.2
.I changed the line implementation "androidx.compose.ui:ui" to implementation ‘androidx.compose.ui:ui:1.4.0-beta02’ and it works
Fix
As mentioned previously, the fix is to bump compose-ui to
1.4.0-beta02
:(or via Version Catalogs🙂
Or to use 2023.02.00-beta03 of the alpha Compose BoM:
(or via Version Catalogs🙂
Rationale
This is because the
androidx.compose.ui_ui.version
file (in theMETA-INF
directory of a built APK) that the Layout Inspector expects has an invalid version:(Curiously enough, this also happens for some other dependency versions:)
(
androidx.browser_browser.version
)Some quick googling in Google’s IssueTracker led to an issue, which documents the bug affecting versions
1.4.0-alpha05
,1.4.0-alpha06
and1.4.0-beta01
.A fix was then submitted to resolve the version issue, and has since been applied to
1.4.0-beta02
(released on 22 Feb).Additional info
This bug appears to have been caused by a prior change to convert the properties in the
VersionFileWriterTask
file (used to write the version file) to use Gradle’s lazily configured properties:However, as
version
is now wrapped around Gradle’sProperty
interface, it will then require additional code to retrieve its value, in this case with a simpleget()
call (as shown in the most recent commit):