TaskInputs.files: NoSuchMethodError

(Carlo Luib-Finetti) #1

I have a task method defined, taking some type and using the files method as source to from. While this is working with Gradle 4.6, it results into TaskInputs.files: NoSuchMethodError. I cannot figure out why. Any tips?

(Stefan Wolf) #2

Hi Carlo,

could you maybe provide the full code example? There is a TaskInputs.files method in Gradle 5.0 (I guess that is the version when it fails), but a bridge method has been removed. Maybe that is causing the problems you are seeing.


(Carlo Luib-Finetti) #3

The code is not mine, but from an open source project. Here it is:

task svgToPng(type: fr.avianey.androidsvgdrawable.gradle.SvgDrawableTask) {
    from = files('graphics')
    to = file('res')
    targetedDensities = ['hdpi', 'xhdpi', 'xxhdpi', 'xxxhdpi']
    outputFormat = 'PNG'
    outputType = 'mipmap'

It works with Gradle 4.6 (which is the projects version), but not with 5.0 or 5.1. I’m just curious, why not.

(Carlo Luib-Finetti) #4

@Stefan_Wolf: can you reproduce the problem? And how could or should this be fixed?

(Stefan Wolf) #5

If you can provide me with a link to the open source project and some steps how to reproduce it I may have a better idea what is going on. Currently, I don’t know why files would use TaskInputs.files and not Project.files.

(Carlo Luib-Finetti) #6

It’s the - in Germany - famous ‘Oeffi’ project; the gradle build is at https://gitlab.com/oeffi/oeffi/blob/master/oeffi/build.gradle.

(Stefan Wolf) #7

Thanks, I found the problem. The actual call is in the task class: https://github.com/avianey/androidsvgdrawable-plugin/blob/master/plugin/gradle/src/main/java/fr/avianey/androidsvgdrawable/gradle/SvgDrawableTask.java#L72

This class is compiled against Gradle 2.2.1 where this method still returns TaskInputs. We kept the old method as a bridge method until it was removed in Gradle 5.0. The new methods seem to be there since Gradle 3.0.

So the plugin would need to be recompiled against Gradle 3.0 to work with Gradle 5.x.


(Carlo Luib-Finetti) #8

Thanks Stefan for your investigation!