Skip to content
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

[Component.Resources] Generating an APK throws error due to task dependency implication #4085

Closed
yuroyami opened this issue Dec 30, 2023 · 12 comments
Assignees
Labels
bug Something isn't working external bug Bug in an external software other than CM/Skiko resources

Comments

@yuroyami
Copy link

Kotiln: 2.0.0-Beta1 and 1.9.21
Compose version: 1.6.0-dev1350

When I try to release an APK from my project, two tasks throw an error, both of which say that "they use output from this task :shared:copyFontsToAndroidAssets without declaring an explicit or implicit dependency".

These two tasks are: :shared:generateReleaseLintVitalModel and :shared:lintVitalAnalyzeRelease

The stacktrace:

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
A problem was found with the configuration of task ':shared:generateReleaseLintVitalModel' (type 'LintModelWriterTask').
  - Gradle detected a problem with the following location: '/Users/mac/WORKSTATION/SyncplayMobile/shared/build/generated/compose/resourceGenerator/androidFonts'.
    
    Reason: Task ':shared:generateReleaseLintVitalModel' uses this output of task ':shared:copyFontsToAndroidAssets' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':shared:copyFontsToAndroidAssets' as an input of ':shared:generateReleaseLintVitalModel'.
      2. Declare an explicit dependency on ':shared:copyFontsToAndroidAssets' from ':shared:generateReleaseLintVitalModel' using Task#dependsOn.
      3. Declare an explicit dependency on ':shared:copyFontsToAndroidAssets' from ':shared:generateReleaseLintVitalModel' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.5/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem was found with the configuration of task ':shared:lintVitalAnalyzeRelease' (type 'AndroidLintAnalysisTask').
  - Gradle detected a problem with the following location: '/Users/mac/WORKSTATION/SyncplayMobile/shared/build/generated/compose/resourceGenerator/androidFonts'.
    
    Reason: Task ':shared:lintVitalAnalyzeRelease' uses this output of task ':shared:copyFontsToAndroidAssets' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':shared:copyFontsToAndroidAssets' as an input of ':shared:lintVitalAnalyzeRelease'.
      2. Declare an explicit dependency on ':shared:copyFontsToAndroidAssets' from ':shared:lintVitalAnalyzeRelease' using Task#dependsOn.
      3. Declare an explicit dependency on ':shared:copyFontsToAndroidAssets' from ':shared:lintVitalAnalyzeRelease' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.5/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
==============================================================================
@yuroyami yuroyami added bug Something isn't working submitted labels Dec 30, 2023
@yuroyami
Copy link
Author

As a workaround, adding this to my shared module's build.gradle.kts would resolve the issue:

tasks.withType<AndroidLintAnalysisTask>{
    dependsOn("copyFontsToAndroidAssets")
}

tasks.withType<LintModelWriterTask>{
    dependsOn("copyFontsToAndroidAssets")
}

This might be a Gradle plugin/wrapper incompatibility though. I am still not sure.
I am using Gradle 8.5 and AGP 8.2.0.

@eymar
Copy link
Member

eymar commented Jan 2, 2024

Could you please provide a minimal reproducer project?

Have you tried other gradle and AGP versions?

These two tasks are: :shared:generateReleaseLintVitalModel and :shared:lintVitalAnalyzeRelease

These two tasks are not added by Compose Multiplatform. I guess they're added by AGP. So I think it's worth trying with different AGP versions.

@eymar eymar added wait for reply Further information is requested external bug Bug in an external software other than CM/Skiko labels Jan 2, 2024
xfqwdsj added a commit to fhraise/Fhraise that referenced this issue Jan 20, 2024
@eskatos
Copy link

eskatos commented Jan 25, 2024

It looks to me this is related with the new resources in 1.6.0

Gradle detected a problem with the following location: '/path/to/project/build/generated/compose/resourceGenerator/androidFonts'.

@arkivanov
Copy link
Contributor

I've also encountered this. Steps to reproduce:

  1. Generate a new project using the KMP Wizard
  2. Update compose-plugin dependency from 1.6.0-alpha01 to 1.6.0-beta01
  3. Run ./gradlew :composeApp:build

It fails with:

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':composeApp:lintVitalAnalyzeRelease' (type 'AndroidLintAnalysisTask').
  - Gradle detected a problem with the following location: '/Users/arkivanov/Downloads/Miner/composeApp/build/generated/compose/resourceGenerator/androidFonts'.
    
    Reason: Task ':composeApp:lintVitalAnalyzeRelease' uses this output of task ':composeApp:copyFontsToAndroidAssets' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':composeApp:copyFontsToAndroidAssets' as an input of ':composeApp:lintVitalAnalyzeRelease'.
      2. Declare an explicit dependency on ':composeApp:copyFontsToAndroidAssets' from ':composeApp:lintVitalAnalyzeRelease' using Task#dependsOn.
      3. Declare an explicit dependency on ':composeApp:copyFontsToAndroidAssets' from ':composeApp:lintVitalAnalyzeRelease' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.4/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

If I updated AGP from 8.1.4 to 8.2.2, then the build fails with:

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':composeApp:generateReleaseLintVitalReportModel' (type 'LintModelWriterTask').
  - Gradle detected a problem with the following location: '/Users/arkivanov/Downloads/Miner/composeApp/build/generated/compose/resourceGenerator/androidFonts'.
    
    Reason: Task ':composeApp:generateReleaseLintVitalReportModel' uses this output of task ':composeApp:copyFontsToAndroidAssets' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':composeApp:copyFontsToAndroidAssets' as an input of ':composeApp:generateReleaseLintVitalReportModel'.
      2. Declare an explicit dependency on ':composeApp:copyFontsToAndroidAssets' from ':composeApp:generateReleaseLintVitalReportModel' using Task#dependsOn.
      3. Declare an explicit dependency on ':composeApp:copyFontsToAndroidAssets' from ':composeApp:generateReleaseLintVitalReportModel' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.4/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

@alpine12
Copy link

alpine12 commented Feb 3, 2024

As a workaround, adding this to my shared module's build.gradle.kts would resolve the issue:

tasks.withType<AndroidLintAnalysisTask>{
    dependsOn("copyFontsToAndroidAssets")
}

tasks.withType<LintModelWriterTask>{
    dependsOn("copyFontsToAndroidAssets")
}

This might be a Gradle plugin/wrapper incompatibility though. I am still not sure. I am using Gradle 8.5 and AGP 8.2.0.

This saved me from errors after updating to version 1.6.0-beta01.

@pjBooms pjBooms removed wait for reply Further information is requested submitted labels Feb 6, 2024
terrakok added a commit that referenced this issue Feb 6, 2024
@terrakok
Copy link
Member

terrakok commented Feb 6, 2024

#4247

@skolson
Copy link

skolson commented Feb 7, 2024

In case this is helpful, I'm also seeing this, on release builds only, using these:

  • gradle 8.6
  • AGP: 8.4.0-alpha08
  • Compose MP: 1.6.0-beta02

Project uses the composeResources support for a few drawables (PNG images). In this project all the compose multiplatform code is in a separate module named "uiCommon". There are 4 other modules in the project, and only the uiCommon module gets these gradle errors that make release builds fail. The gradle errors displayed all suggest the gradle task dependencies below are required and are missing (I'm cherry-picking from the output):

A problem was found with the configuration of task ':uiCommon:generateReleaseLintModel' (type 'LintModelWriterTask').
      1. Declare task ':uiCommon:copyFontsToAndroidAssets' as an input of ':uiCommon:generateReleaseLintModel'.

A problem was found with the configuration of task ':uiCommon:lintVitalAnalyzeRelease' (type 'AndroidLintAnalysisTask').
      1. Declare task ':uiCommon:copyFontsToAndroidAssets' as an input of ':uiCommon:lintVitalAnalyzeRelease'.

A problem was found with the configuration of task ':uiCommon:generateReleaseLintVitalModel' (type 'LintModelWriterTask').
      1. Declare task ':uiCommon:copyFontsToAndroidAssets' as an input of ':uiCommon:generateReleaseLintVitalModel'.

So it looks like at a minimum tasks generateReleaseLintVitalModel, lintVitalAnalyzeRelease, and generateReleaseLintModel all need task copyFontsToAndroidAssets as an input or an explicit dependency.

@skolson
Copy link

skolson commented Feb 7, 2024

Oh, and I forgot to mention I can confirm that the same work-around from alpine12 also fixes my build.

@terrakok terrakok closed this as completed Feb 7, 2024
@terrakok
Copy link
Member

terrakok commented Feb 7, 2024

#4247

@Junzz0
Copy link

Junzz0 commented Jun 28, 2024

gradle = gradle-8.8-all.zip
androidGradlePlugin = "8.2.0"
composeMultiplatform = "1.7.0-dev1698"
kotlin = "2.0.0"

Still having the same issue.

Because IDEA 2024.1.4 only supports 8.2.0, AGP cannot be upgraded temporarily.

@terrakok

@Junzz0
Copy link

Junzz0 commented Jun 28, 2024

If I need to upgrade AGP, then I need to wait for 2024.2 to be released.

https://www.jetbrains.com/idea/nextversion/

@okushnikov
Copy link
Collaborator

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

@JetBrains JetBrains locked and limited conversation to collaborators Dec 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working external bug Bug in an external software other than CM/Skiko resources
Projects
None yet
Development

No branches or pull requests

10 participants