Skip to content

Update to Compose 1.8 #1555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 25, 2025
Merged

Update to Compose 1.8 #1555

merged 3 commits into from
Apr 25, 2025

Conversation

dturner
Copy link
Contributor

@dturner dturner commented Apr 23, 2025

I have updated all projects to the latest version of Compose (1.8) which was released today. More info here.

I encountered the following issues and have documented their resolutions below:

Could not get unknown property 'keepUnusedLibraries'
After updating the version-catalog-update-plugin from 0.8.5 to 1.0.0 I received the following error:

Could not get unknown property 'keepUnusedLibraries' for extension 'versionCatalogUpdate' property 'keep' of type nl.littlerobots.vcu.plugin.KeepConfiguration.

Cause: The plugin no longer supports various keep properties.
Fix: Remove the unsupported keep properties from the build config.
More info: here and here

Minimum supported Gradle version is 8.11.1. Current version is 8.10.2.
Fix: Search and replace gradle-8.10.2-bin.zip with gradle-8.13-bin.zip throughout repo

Suspend function 'suspend fun navigateBack(backNavigationBehavior: BackNavigationBehavior): Boolean' can only be called from a coroutine or another suspend function.

Full error:

e: file:///Users/donturner/Code/workspace-android/compose-samples/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt:268:19 Suspend function 'suspend fun navigateBack(backNavigationBehavior: BackNavigationBehavior): Boolean' can only be called from a coroutine or another suspend function.

Root cause: ThreePaneScaffoldNavigator.navigateBack became a suspend fun.
Fix: Wrap navigate calls in coroutineScope.launch

Unresolved reference ThreePaneScaffoldNavigator.currentDestination.content
Cause: Property name changed from content to contentKey
Fix: Change to contentKey

Core library desugaring runtime library version 1.2.2 does not support compileSdk=35 or later; please upgrade to version 2.1.5
Fix: Update jdkDesugar to 2.1.5

Failed to apply plugin 'com.diffplug.spotless'.
Cause: scripts/verify_samples.sh still assumed that the spotless config would be in a separate init file, but no longer does following this PR.
Fix: Update scripts/verify_samples.sh to use the spotlessCheck task from each app's build.gradle.kts.

Spotless formatting issues
Home.kt from Jetcaster had formatting issues. Running spotlessApply fixes the issues but also changes code that isn't directly related to the version updates and makes reviewing difficult. For the purposes of reviewing, the original changes are in this commit.

@dturner dturner requested a review from a team as a code owner April 23, 2025 23:13
@dturner dturner requested a review from bentrengrove April 23, 2025 23:13
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @dturner, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request updates the Compose version to 1.8 across multiple projects (JetLagged, JetNews, Jetcaster, Jetchat, Jetsnack, and Reply). It also addresses several issues encountered during the update, including changes required by the version catalog update plugin, Gradle version updates, and necessary code modifications due to API changes in Compose Material3 Adaptive. The script duplicate_version_config.sh was modified to stop copying the spotless config, and the script verify_samples.sh was updated to use the spotlessCheck task from each app's build.gradle.kts.

Highlights

  • Compose Version Update: Updates all projects to Compose version 1.8.
  • Version Catalog Update Plugin: Removes unsupported keep properties from build configurations due to changes in the version catalog update plugin (0.8.5 to 1.0.0).
  • Gradle Version Update: Updates the Gradle version from 8.10.2 to 8.13 to meet the minimum supported version.
  • Code Modifications for Material3 Adaptive: Wraps navigate calls in coroutineScope.launch due to ThreePaneScaffoldNavigator.navigateBack becoming a suspend function. Also, updates property name from content to contentKey.
  • JDK Desugar Update: Updates jdkDesugar to version 2.1.5 to support compileSdk=35 or later.
  • Spotless Plugin Configuration: Updates scripts/verify_samples.sh to use the spotlessCheck task from each app's build.gradle.kts.

Changelog

Click here to see the changelog
  • JetLagged/buildscripts/toml-updater-config.gradle
    • Removed unsupported keepUnusedLibraries and keepUnusedPlugins properties.
  • JetLagged/gradle/libs.versions.toml
    • Updated versions for accompanist, androidGradlePlugin, androidx-activity-compose, androidx-compose-bom, androidx-corektx, androidx-navigation, coroutines, hilt, horologist, kotlin, ksp, roborazzi, room, and version-catalog-update.
    • Added android-material3 version.
  • JetLagged/gradle/wrapper/gradle-wrapper.properties
    • Updated Gradle distribution URL to gradle-8.13-bin.zip.
  • JetNews/buildscripts/toml-updater-config.gradle
    • Removed unsupported keepUnusedLibraries and keepUnusedPlugins properties.
  • JetNews/gradle/libs.versions.toml
    • Updated versions for accompanist, androidGradlePlugin, androidx-activity-compose, androidx-compose-bom, androidx-corektx, androidx-navigation, coroutines, hilt, horologist, kotlin, ksp, roborazzi, room, and version-catalog-update.
    • Added android-material3 version.
  • JetNews/gradle/wrapper/gradle-wrapper.properties
    • Updated Gradle distribution URL to gradle-8.13-bin.zip.
  • Jetcaster/buildscripts/toml-updater-config.gradle
    • Removed unsupported keepUnusedLibraries and keepUnusedPlugins properties.
  • Jetcaster/gradle/libs.versions.toml
    • Updated versions for accompanist, androidGradlePlugin, androidx-activity-compose, androidx-compose-bom, androidx-corektx, androidx-navigation, coroutines, hilt, horologist, kotlin, ksp, roborazzi, room, and version-catalog-update.
    • Updated jdkDesugar to 2.1.5
    • Added android-material3 version.
    • Removed duplicate android-material3 entry under libraries.
  • Jetcaster/gradle/wrapper/gradle-wrapper.properties
    • Updated Gradle distribution URL to gradle-8.13-bin.zip.
    • Removed copyright header.
  • Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt
    • Updated copyright year to 2020-2025.
    • Added import for NavigableSupportingPaneScaffold
    • Simplified isMainPaneHidden() function.
    • Added default value for verticalHingePolicy in calculateScaffoldDirective().
    • Simplified getExcludedVerticalBounds() function.
    • Added trailing commas to function calls.
    • Wrapped navigator.navigateBack() and navigator.navigateTo() calls in coroutineScope.launch.
    • Changed navigator.currentDestination?.content to navigator.currentDestination?.contentKey.
  • Jetchat/buildscripts/toml-updater-config.gradle
    • Removed unsupported keepUnusedLibraries and keepUnusedPlugins properties.
  • Jetchat/gradle/libs.versions.toml
    • Updated versions for accompanist, androidGradlePlugin, androidx-activity-compose, androidx-compose-bom, androidx-corektx, androidx-navigation, coroutines, hilt, horologist, kotlin, ksp, roborazzi, room, and version-catalog-update.
    • Added android-material3 version.
  • Jetchat/gradle/wrapper/gradle-wrapper.properties
    • Updated Gradle distribution URL to gradle-8.13-bin.zip.
  • Jetsnack/buildscripts/toml-updater-config.gradle
    • Removed unsupported keepUnusedLibraries and keepUnusedPlugins properties.
  • Jetsnack/gradle/libs.versions.toml
    • Updated versions for accompanist, androidGradlePlugin, androidx-activity-compose, androidx-compose-bom, androidx-corektx, androidx-navigation, coroutines, hilt, horologist, kotlin, ksp, roborazzi, room, and version-catalog-update.
    • Added android-material3 version.
  • Jetsnack/gradle/wrapper/gradle-wrapper.properties
    • Updated Gradle distribution URL to gradle-8.13-bin.zip.
  • Reply/buildscripts/toml-updater-config.gradle
    • Removed unsupported keepUnusedLibraries and keepUnusedPlugins properties.
  • Reply/gradle/libs.versions.toml
    • Updated versions for accompanist, androidGradlePlugin, androidx-activity-compose, androidx-compose-bom, androidx-corektx, androidx-navigation, coroutines, hilt, horologist, kotlin, ksp, roborazzi, room, and version-catalog-update.
    • Added android-material3 version.
  • Reply/gradle/wrapper/gradle-wrapper.properties
    • Updated Gradle distribution URL to gradle-8.13-bin.zip.
  • scripts/duplicate_version_config.sh
    • Commented out the lines that copy init.gradle.kts to each project's buildscripts directory.
  • scripts/libs.versions.toml
    • Updated versions for accompanist, androidGradlePlugin, androidx-activity-compose, androidx-compose-bom, androidx-corektx, androidx-navigation, coroutines, hilt, horologist, kotlin, ksp, roborazzi, room, and version-catalog-update.
    • Added android-material3 version.
    • Added spotless plugin
  • scripts/toml-updater-config.gradle
    • Removed unsupported keepUnusedLibraries and keepUnusedPlugins properties.
  • scripts/verify_samples.sh
    • Removed --init-script buildscripts/init.gradle.kts from the spotlessCheck command.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A version bump so grand,
Across projects, hand in hand.
Compose evolves,
As code resolves,
A fresher, smoother Android land.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Compose version across multiple projects and addresses several compatibility issues. The changes seem well-documented and the resolutions are clearly explained in the pull request description. However, there are a few areas that could be improved.

Summary of Findings

  • jdkDesugar version update: The jdkDesugar version is updated in Jetcaster but not consistently across all projects. It should be updated in all projects to ensure compatibility with compileSdk=35.
  • Inconsistent android-material3 dependency declaration: The android-material3 dependency is added as a library in some libs.versions.toml files but also declared directly in the Jetcaster/gradle/libs.versions.toml file, which is then removed. This inconsistency should be resolved.
  • Coroutine scope usage for navigation: The fix for the navigateBack suspend function involves wrapping calls in coroutineScope.launch. Ensure that the coroutine scope being used is properly scoped to the lifecycle of the composable to avoid potential memory leaks or unexpected behavior.
  • Spotless config: The PR description mentions that the spotless config is no longer in a separate init file. However, the duplicate_version_config.sh script still has commented-out lines that attempt to copy the init.gradle.kts file. This discrepancy should be addressed.

Merge Readiness

The pull request is almost ready for merging. However, the inconsistencies with the jdkDesugar version and android-material3 dependency declaration need to be addressed. Additionally, the duplicate_version_config.sh script should be updated to reflect the changes in the spotless configuration. Once these issues are resolved, the pull request should be good to merge. I am unable to approve this pull request, and recommend that others review and approve this code before merging.

@dturner dturner marked this pull request as draft April 23, 2025 23:29
@dturner dturner marked this pull request as ready for review April 24, 2025 09:03
@dturner dturner merged commit e472f98 into main Apr 25, 2025
25 of 31 checks passed
@dturner dturner deleted the dt/compose-1.8 branch April 25, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants