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?
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.versionfile (in theMETA-INFdirectory 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-alpha06and1.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
VersionFileWriterTaskfile (used to write the version file) to use Gradle's lazily configured properties:However, as
versionis now wrapped around Gradle'sPropertyinterface, it will then require additional code to retrieve its value, in this case with a simpleget()call (as shown in the most recent commit):