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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ android {
signingConfigs.release : signingConfigs.debug
}
}

lint {
// For docs on options available here:
// https://developer.android.com/reference/tools/gradle-api/8.5/com/android/build/api/dsl/Lint
checkAllWarnings = true
warningsAsErrors = true
}
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
Expand Down
1 change: 0 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
android:taskAffinity=""
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:networkSecurityConfig="@xml/network_security_config"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
Expand Down
12 changes: 0 additions & 12 deletions android/app/src/main/res/drawable-v21/launch_background.xml

This file was deleted.

2 changes: 1 addition & 1 deletion android/app/src/main/res/drawable/launch_background.xml
Original file line number Diff line number Diff line change
@@ -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.


<!-- You can insert your own image assets here -->
<!-- <item>
Expand Down
29 changes: 0 additions & 29 deletions android/app/src/main/res/xml/network_security_config.xml

This file was deleted.

9 changes: 9 additions & 0 deletions tools/check
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,15 @@ run_android() {
files_check android/ \
|| return 0

# 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 \
|| return

flutter build apk \
|| return

Expand Down