Skip to content

Linting causes build to fail #2

@mschwaig

Description

@mschwaig

While attempting to build another Android project with this approach, but more recent Gradle and other tooling versions, I ran into an issue where the linting tasks would make the build fail, because Gradle could not find com.android.tools.lint:lint-gradle.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:lintVitalAnalyzeRelease'.
> Could not resolve all files for configuration ':app:detachedConfiguration1'.
   > Could not find com.android.tools.lint:lint-gradle:30.2.2.
     Searched in the following locations:
       - file:/nix/store/lcq86p5p69w0vk2p8w8icvw5gwsb5a3f-nix-maven-repo/com/android/tools/lint/lint-gradle/30.2.2/lint-gradle-30.2.2.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'me>
     Required by:
         project :app

* Try:
> Run with --debug option to get more log output.
> Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:lintVitalAnalyzeRelease'.
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:38)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)

com.android.tools.lint:lint-gradle does not seem to be a regular dependency that is listed in deps.json. Maybe it would require similar special casing to what you did for org.gradle.project.android.aapt2 inside build.nix, but I also can't find that jar in the Android SDK.

I ended up working around that issue for now by skipping the lint tasks, but maybe there's a better fix.

diff --git b/build.nix a/build.nix
index d0f8212..4a7201e 100644
--- b/build.nix
+++ a/build.nix
@@ -24,7 +24,9 @@ stdenv.mkDerivation {
       --offline --no-daemon --no-build-cache --info --full-stacktrace \
       --warning-mode=all --parallel --console=plain \
       -PnixMavenRepo=file://${mavenRepo} \
-      -Dorg.gradle.project.android.aapt2FromMavenOverride=$ANDROID_HOME/share/android-sdk/build-tools/33.0.0/aapt2
+      -Dorg.gradle.project.android.aapt2FromMavenOverride=$ANDROID_HOME/share/android-sdk/build-tools/33.0.0/aapt2 \
+      -x :app:lintVitalRelease \
+      -x :app:lint # TODO: find out why gradle-lint jar is missing
     runHook postBuild
   '';

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions