Skip to content

Run Android linter; get our tree clean of those lints #797

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
Jul 10, 2024

Conversation

gnprice
Copy link
Member

@gnprice gnprice commented Jul 8, 2024

Stacked atop #796.

This adds the Android linter:
https://developer.android.com/studio/write/lint
to what we run in CI.

Then it turns out there are a couple of things that linter finds in our existing tree. So fix those first.

@chrisbobbe
Copy link
Collaborator

Looks like something is missing in the CI testing environment. Quoting the test failure:

================================================================
Running android...
tools/gradle: line 9: /home/runner/work/zulip-flutter/zulip-flutter/android/gradlew: No such file or directory

@gnprice
Copy link
Member Author

gnprice commented Jul 8, 2024

Yeah, fixing now

@gnprice gnprice force-pushed the pr-android-lint branch from e76346a to f652dea Compare July 8, 2024 23:31
@gnprice
Copy link
Member Author

gnprice commented Jul 8, 2024

The fix (I think — we'll see if this CI run passes) was:

+    # This causes `android/gradlew` to exist, for `tools/gradle` to use.
+    flutter build apk --config-only \
+    || return
+
     # For docs on this Android linter:
     #   https://developer.android.com/studio/write/lint
     tools/gradle -q :app:lint \

Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

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

Cool! LGTM assuming CI passes. I'll hold off merging until @rajveermalviya has a chance to look, as I did in #796.

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<item android:drawable="?android:colorBackground" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

android [nfc]: Merge drawable-v21/ into drawable/

Our minSdkVersion is no less than 21 -- in fact it's 28 -- so the
app only ever runs on devices that will pick the v21 version over
the baseline version.  So simplify that variation away.

This may break local Android builds in an existing worktree;
it seems like the Android Gradle Plugin is inappropriately caching
where it expects to find this file and gets confused when that copy
goes missing.  The error looks like this:

    * What went wrong:
    Execution failed for task ':app:processDebugResources'.
    > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
       > Android resource linking failed
         com.zulip.flutter.app-mergeDebugResources-32:/values/values.xml:213: error: resource drawable/launch_background (aka com.zulip.flutter:drawable/launch_background) not found.
         […]

To fix, clear the relevant cached data by running:

  $ tools/gradle -q --rerun-tasks \
      :app:bundleDebugResources :app:bundleReleaseResources

Cool, that fix worked. My error was slightly different: it was talking about "release resources" instead of "debug resources", because tools/check android apparently makes a release build. Is it intended to make a release build, by the way?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it'll be "debug resources" if e.g. you hit this as part of flutter run (and I guess don't pass --release or --profile).

I think a release build is a bit more important to exercise here than a debug build, because if there's some issue that one of them trips but not the other, then the release build is much more likely to give us a belated surprise.

Copy link
Member

@rajveermalviya rajveermalviya left a comment

Choose a reason for hiding this comment

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

Thanks LGTM!

Same as the previous Android build PR (#796 (review)), there isn't any difference when M1 runner is used: https://github.com/rajveermalviya/zulip-flutter/actions/runs/9854961236/job/27208869364

Which makes me believe most of the time is spent in dependency downloads, that could be cached, not a reason to block this PR though.

gnprice added 3 commits July 9, 2024 21:05
This was introduced in cffb112 / zulip#474 because we thought it
would be a fix for zulip#461.  As discussed on that issue thread,
though, it turns out this file doesn't have an effect on the
Dart HTTP implementation, which we use.

Since it looks like it's doing something but in fact it isn't,
cut it out to avoid confusion.  It'll still be there in the
Git history if we later want to use it as part of a future
effort to fix zulip#461.
Our minSdkVersion is no less than 21 -- in fact it's 28 -- so the
app only ever runs on devices that will pick the v21 version over
the baseline version.  So simplify that variation away.

This may break local Android builds in an existing worktree;
it seems like the Android Gradle Plugin is inappropriately caching
where it expects to find this file and gets confused when that copy
goes missing.  The error looks like this:

    * What went wrong:
    Execution failed for task ':app:processDebugResources'.
    > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
       > Android resource linking failed
         com.zulip.flutter.app-mergeDebugResources-32:/values/values.xml:213: error: resource drawable/launch_background (aka com.zulip.flutter:drawable/launch_background) not found.
         […]

To fix, clear the relevant cached data by running:

  $ tools/gradle -q --rerun-tasks \
      :app:bundleDebugResources :app:bundleReleaseResources
@gnprice gnprice merged commit ba829c6 into zulip:main Jul 10, 2024
1 check passed
@gnprice
Copy link
Member Author

gnprice commented Jul 10, 2024

Thanks for the reviews! Merging.

@gnprice gnprice deleted the pr-android-lint branch July 10, 2024 04:06
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.

3 participants