skip to Main Content

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


  1. Chosen as BEST ANSWER

    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

    androidx.compose = '2023.02.00-beta02'
    

    And change the version of ui:ui to

    implementation 'androidx.compose.ui:ui:1.4.0-beta02'
    //keep in mind: "" is not the same as ''
    

    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

    androidx.compose = '2023.02.00-beta03'
    

    Also does the trick.


  2. You may want to try updating to the latest version to see if that helps:

    api(platform("dev.chrisbanes.compose:compose-bom:2023.02.00-beta02"))
    

    The current kotlinCompilerExtensionVersion is 1.4.2.

    Login or Signup to reply.
  3. I changed the line implementation "androidx.compose.ui:ui" to implementation ‘androidx.compose.ui:ui:1.4.0-beta02’ and it works

    Login or Signup to reply.
  4. Fix

    As mentioned previously, the fix is to bump compose-ui to 1.4.0-beta02:

    implementation("androidx.compose.ui:ui:1.4.0-beta02")
    

    (or via Version Catalogs🙂

    name-of-library = "androidx.compose.ui:ui:1.4.0-beta02"
    # Or
    name-of-library = { module = "androidx.compose.ui:ui", version = "1.4.0-beta02" }
    

    Or to use 2023.02.00-beta03 of the alpha Compose BoM:

    implementation(platform("dev.chrisbanes.compose:compose-bom:2023.02.00-beta03"))
    

    (or via Version Catalogs🙂

    name-of-bom = "dev.chrisbanes.compose:compose-bom:2023.02.00-beta03"
    # Or
    name-of-bom = { module = "dev.chrisbanes.compose:compose-bom", version = "2023.02.00-beta03" }
    

    Rationale

    This is because the androidx.compose.ui_ui.version file (in the META-INF directory of a built APK) that the Layout Inspector expects has an invalid version:

    task ':compose:ui:ui:writeVersionFile' property 'version'
    

    (Curiously enough, this also happens for some other dependency versions:)

    (androidx.browser_browser.version)

    task ':browser:browser:writeVersionFile' property '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 and 1.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:

    @get:Input
    lateinit var version: String // Before
    abstract val version: Property<String> // After (note the use of Property)
    

    However, as version is now wrapped around Gradle’s Property interface, it will then require additional code to retrieve its value, in this case with a simple get() call (as shown in the most recent commit):

    writer.println(version) // Before
    writer.println(version.get()) // After
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search