Skip to content

Consider warnings-as-errors for plugin CI builds #91868

Closed

Description

@stuartmorgan-g

This is something I was thinking about based on this comment, but would apply to iOS as well (and macOS): the way the native code for plugins on some platforms is built, the build environment may change in ways that create warnings (e.g., the way the Flutter tool updates the min deployment version on iOS to match the app's min deployment version frequently creates deprecation warnings that don't exist in our builds), so we generally don't want to make warnings errors to avoid breaking plugin clients. However, that means warnings aren't surfaced in our CI, which in practice means we don't notice when new ones are added by PRs, which makes warnings kind of useless.

I think we should consider either:

  1. modifying the build on disk before building in CI to add -Werror, or
  2. add build output parsing to notice errors, and fail the CI step.

Both have some maintenance complexity, but continuing to ignore warnings on the native side doesn't seem like a good option.

/cc @blasten @jmagman

Activity

  1. added
    c: contributor-productivityTeam-specific productivity, code health, technical debt.
    p: toolingAffects the flutter_plugin_tools package
    P2Important issues not at the top of the work list
    on Oct 15, 2021
  2. stuartmorgan-g commented on Oct 15, 2021

    @stuartmorgan-g
    ContributorAuthor

    The build context is sightly different though, right? For instance, IIRC it didn't flag availability checks that we didn't need after bumping the example app minimum versions. (Or maybe that's just not a warning under our current settings?)

  3. stuartmorgan-g commented on Jan 31, 2023

    @stuartmorgan-g
    ContributorAuthor

    See also: --fatal-warnings in flutter build, and related discussion in flutter-team-archive/plugins#7062

  4. stuartmorgan-g commented on Mar 2, 2023

    @stuartmorgan-g
    ContributorAuthor

    See also: --fatal-warnings in flutter build, and related discussion in flutter/plugins#7062

    I spun this out into #121819

    For this issue, all that's left is fully enabling Android warnings as errors. flutter/packages#3293 sets up the structure and does it for some packages, but we need to get it enabled for the remaining packages as well. Each of these has the arguments commented out in build.gradle with a reference to this issue:

  5. added
    packageflutter/packages repository. See also p: labels.
    and removed on Mar 5, 2023
  6. navaronbracke commented on Mar 5, 2023

    @navaronbracke
    Contributor

    @stuartmorgan So I went ahead and enabled the compiler options for video_player_android, just to see what the fallout would look like.

    I get a bunch of errors relating to annotations inside ExoPlayer itself:

    Logs
    navaronbracke@MacBook-Pro-van-Navaron example % flutter build apk --release     
    
    💪 Building with sound null safety 💪
    
    Warning: unexpected element (uri:"", local:"extension-level"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
    Warning: unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
    /Users/navaronbracke/.gradle/caches/transforms-3/17d52bfcf76ba92f8a9219102f650808/transformed/jetified-exoplayer-common-2.18.1-api.jar(/com/google/android/exoplayer2/C.class): warning: Cannot find annotation method 'replacement()' in type 'InlineMe': class file for com.google.errorprone.annotations.InlineMe not found
    /Users/navaronbracke/.gradle/caches/transforms-3/17d52bfcf76ba92f8a9219102f650808/transformed/jetified-exoplayer-common-2.18.1-api.jar(/com/google/android/exoplayer2/C.class): warning: Cannot find annotation method 'imports()' in type 'InlineMe'
    /Users/navaronbracke/.gradle/caches/transforms-3/17d52bfcf76ba92f8a9219102f650808/transformed/jetified-exoplayer-common-2.18.1-api.jar(/com/google/android/exoplayer2/C.class): warning: Cannot find annotation method 'replacement()' in type 'InlineMe'
    /Users/navaronbracke/.gradle/caches/transforms-3/17d52bfcf76ba92f8a9219102f650808/transformed/jetified-exoplayer-common-2.18.1-api.jar(/com/google/android/exoplayer2/C.class): warning: Cannot find annotation method 'imports()' in type 'InlineMe'
    /Users/navaronbracke/.gradle/caches/transforms-3/17d52bfcf76ba92f8a9219102f650808/transformed/jetified-exoplayer-common-2.18.1-api.jar(/com/google/android/exoplayer2/C.class): warning: Cannot find annotation method 'replacement()' in type 'InlineMe'
    /Users/navaronbracke/.gradle/caches/transforms-3/17d52bfcf76ba92f8a9219102f650808/transformed/jetified-exoplayer-common-2.18.1-api.jar(/com/google/android/exoplayer2/C.class): warning: Cannot find annotation method 'imports()' in type 'InlineMe'
    /Users/navaronbracke/.gradle/caches/transforms-3/17d52bfcf76ba92f8a9219102f650808/transformed/jetified-exoplayer-common-2.18.1-api.jar(/com/google/android/exoplayer2/C.class): warning: Cannot find annotation method 'replacement()' in type 'InlineMe'
    /Users/navaronbracke/.gradle/caches/transforms-3/17d52bfcf76ba92f8a9219102f650808/transformed/jetified-exoplayer-common-2.18.1-api.jar(/com/google/android/exoplayer2/C.class): warning: Cannot find annotation method 'imports()' in type 'InlineMe'
    /Users/navaronbracke/.gradle/caches/transforms-3/17d52bfcf76ba92f8a9219102f650808/transformed/jetified-exoplayer-common-2.18.1-api.jar(/com/google/android/exoplayer2/C.class): warning: Cannot find annotation method 'replacement()' in type 'InlineMe'
    /Users/navaronbracke/.gradle/caches/transforms-3/17d52bfcf76ba92f8a9219102f650808/transformed/jetified-exoplayer-common-2.18.1-api.jar(/com/google/android/exoplayer2/C.class): warning: Cannot find annotation method 'imports()' in type 'InlineMe'
    /Users/navaronbracke/.gradle/caches/transforms-3/17d52bfcf76ba92f8a9219102f650808/transformed/jetified-exoplayer-common-2.18.1-api.jar(/com/google/android/exoplayer2/util/Util.class): warning: Cannot find annotation method 'value()' in type 'EnsuresNonNull': class file for org.checkerframework.checker.nullness.qual.EnsuresNonNull not found
    /Users/navaronbracke/.gradle/caches/transforms-3/17d52bfcf76ba92f8a9219102f650808/transformed/jetified-exoplayer-common-2.18.1-api.jar(/com/google/android/exoplayer2/util/Util.class): warning: Cannot find annotation method 'value()' in type 'EnsuresNonNull'
    error: warnings found and -Werror specified
    1 error
    12 warnings
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':video_player_android:compileReleaseJavaWithJavac'.
    > Compilation failed; see the compiler error output for details.
    
    * 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
    
    BUILD FAILED in 36s
    Running Gradle task 'assembleRelease'...                           38.0s
    Gradle task assembleRelease failed with exit code 1
    

    It builds fine if I remove the compiler args. We might need to bump exoplayer it seems.
    I'll see what it gives when I bump to 2.18.2.

  7. stuartmorgan-g commented on Mar 5, 2023

    @stuartmorgan-g
    ContributorAuthor

    I had a similar missing class file issue with the maps plugin, and was able to work around it by injecting a dependency that defined the missing pieces from the example; I'll have that PR up sometime next week (once I fix the warnings that were married by that initial probably).

  8. stuartmorgan-g commented on Mar 7, 2023

    @stuartmorgan-g
    ContributorAuthor

    @navaronbracke This is what I did for the similar maps issue. It wasn't the same symbols, but if you can find out what package defines the symbols you are missing the same injection approach would likely work.

  9. navaronbracke commented on Mar 7, 2023

    @navaronbracke
    Contributor

    Thanks! I'll take a stab at video_player_android with this in mind.

  10. navaronbracke commented on Mar 8, 2023

    @navaronbracke
    Contributor

    @stuartmorgan Apparently the warnings I get (see the logs in #91868 (comment)) come from two different dependencies:

    1. The InlineMe symbol from com.google.errorprone.annotations
    2. The EnsuresNonNull symbol from org.checkerframework.checker.nullness.qual

    Turns out those are excluded here? https://github.com/google/ExoPlayer/blob/release-v2/library/common/build.gradle#L28-L37

    The versions of those dependencies are defined here: https://github.com/google/ExoPlayer/blob/r2.18.1/constants.gradle

    Edit: Apparently, besides the dependency issue, there were no errors. phew

  11. github-actions commented on Mar 25, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  12. locked as resolved and limited conversation to collaborators on Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: contributor-productivityTeam-specific productivity, code health, technical debt.p: toolingAffects the flutter_plugin_tools packagepackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specifically

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions