irgaly / android-remove-unused-resources-plugin

A gradle plugin to remove unused android resources by Android Lint results xml file.
https://plugins.gradle.org/plugin/io.github.irgaly.remove-unused-resources
Other
29 stars 1 forks source link

Getting a gradle error when syncing without specifying a lintVariant option #89

Closed StylianosGakis closed 1 year ago

StylianosGakis commented 1 year ago

When doing a gradle sync while I got the plugin applied to my :app module, but without specifying some removeUnusedResources {} configuration I get the error:

Can not load tasks for project ':app'

org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreationException: Could not create task ':app:removeUnusedResources'.
... hundreds of lines

Thing is, the way I run this plugin, as seen from the docs too, is that in my CI I do ./gradlew :app:removeUnusedResources -Prur.lintVariant="debug" so I pass the lintVariant there already. When running locally I do the same, so I don't need to configure it for running it locally.

What do you think is the best approach to avoid getting this error?

What do you think?

irgaly commented 1 year ago

Thanks to reporting this issue!

This is a behavior change from v1.4.0 for supporting AGP 8 (#86), but I think this behavior is not suitable as you mentioned it.

I have fixed this problem by #90, and release v1.4.1. Please check with that version.


steps to reproduce:

% ./gradlew :sample:tasks
Type-safe project accessors is an incubating feature.
> Task :sample:tasks FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sample:tasks'.
> Could not create task ':sample:removeUnusedResources'.
   > removeUnusedResources lintVariant or rur.lintVariant is not specified

v1.4.1 will report this error on task running:

% ./gradlew :sample:removeUnusedResources
Type-safe project accessors is an incubating feature.
> Task :sample:removeUnusedResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sample:removeUnusedResources'.
> Could not determine lintResultXml file. You should set a lintVariant option or lintResultXml option directly
StylianosGakis commented 1 year ago

Wow yes, this looks like exactly the fix I was looking for. I just bumped our project and I no longer get this warning. Thanks a lot for the quick release too!