lbarqueira
lbarqueira

Reputation: 1305

Layout inspector not showing composables tree

When I use Layout Inspector in a running compose app on a device, I do not obtain the composables tree but the view system tree. How to see the composables tree? Thanks

enter image description here

Note: As I run Layout inspector in Android Studio, I still get the following error:
Unable to set the global setting: "debug_view_attributes_application_package" to: "com.example.statecodelab" Error: Security exception: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS java.lang.SecurityException: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS at com.android.providers.settings.SettingsProvider.enforceWritePermission(SettingsProvider.java:2340) at com.android.providers.settings.SettingsProvider.mutateGlobalSetting(SettingsProvider.java:1405) at com.android.providers.settings.SettingsProvider.insertGlobalSetting(SettingsProvider.java:1379) at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:556) at android.content.ContentProvider.call(ContentProvider.java:2162) at android.content.ContentProvider$Transport.call(ContentProvider.java:481) at com.android.providers.settings.SettingsService$MyShellCommand.putForUser(SettingsService.java:375) at com.android.providers.settings.SettingsService$MyShellCommand.onCommand(SettingsService.java:277) at android.os.ShellCommand.exec(ShellCommand.java:104) at com.android.providers.settings.SettingsService.onShellCommand(SettingsService.java:49) at android.os.Binder.shellCommand(Binder.java:881) at android.os.Binder.onTransact(Binder.java:765) at android.os.Binder.execTransactInternal(Binder.java:1021) at android.os.Binder.execTransact(Binder.java:994)

Upvotes: 12

Views: 9919

Answers (5)

Jeffrey
Jeffrey

Reputation: 2106

Check for warnings. I accidently deleted a package declaration at the top of one of my composable files. This produced a warning but did not prevent the emulator from running. In Layout Inspector, strangely only part of the tree was visible. It took me a while to catch the warning but when I did, the full composable tree became visible.

Upvotes: 0

evcostt
evcostt

Reputation: 744

that solved it for me:

When only the views are shown, but no Composables, make sure to not exclude .version files from META-INF, since the compose UI tooling utilizes them, e.g. remove/adjust these:

answered by @dipdipdip in Layout inspector not showing compose nodes

packagingOptions {
    resources {
        excludes += "META-INF/**"
    }
}

Upvotes: 2

Ina Galus
Ina Galus

Reputation: 391

Solution for Samsung Galaxy S10 (API 31) Go to Settings -> Developer Options -> Enable option 'Enable view attribute inspection'

Upvotes: 39

lbarqueira
lbarqueira

Reputation: 1305

Finally got it.

Looking at the error: Error: Security exception: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS, I got over this error by enabling the "Disable Permission Monitoring" on Developer options of my mobile phone (realme 6i).

Once I fixed the previous error the Layout inspector for a Compose app works fine.

Note that even though the error described above existed at the time of the post, it was possible to run the Layout inspector but its result was not correct for a jetpack compose application.
I would like to thank all of you that tried to help me solve this issue.

Upvotes: 10

Jemshit
Jemshit

Reputation: 10038

It is probably supported on API >=30

Upvotes: 2

Related Questions