Skip to content

Gradle 7注解@Input失效导致无法打包 #364

@MortalKim

Description

@MortalKim

参照Gradle7的文档中的描述,需要替换注解:

Incorrect use of the @Input annotation
This error indicates that a property is annotated with @Input, but that it should be annotated with @InputFile or @InputDirectory instead.

If you use the @Input annotation on a file-based property, Gradle wouldn’t consider the file contents, or the directory contents, as inputs, as you might expect.

To fix this problem, you need to tell Gradle if the file property represents an input file, in which case you should annotate it with @InputFile, or a directory, in which case it should be annotated with @InputDirectory. If what you really wanted to say is that the actual file path is an input, then you should return a String instead which corresponds to the absolute path of the file.

如果打包的话会报如下错误

* What went wrong:
Some problems were found with the configuration of task ':app:assembleReleaseChannels' (type 'ChannelMaker').
  - Type 'com.meituan.android.walle.ChannelMaker' field 'targetProject' without corresponding getter has been annotated with @Input.

    Reason: Annotations on fields are only used if there's a corresponding getter for the field.

    Possible solutions:
      1. Add a getter for field 'targetProject'.
      2. Remove the annotations on 'targetProject'.

    Please refer to https://docs.gradle.org/7.0.2/userguide/validation_problems.html#ignored_annotations_on_field for more details about this problem.
  - Type 'com.meituan.android.walle.ChannelMaker' field 'variant' without corresponding getter has been annotated with @Input.

    Reason: Annotations on fields are only used if there's a corresponding getter for the field.

    Possible solutions:
      1. Add a getter for field 'variant'.
      2. Remove the annotations on 'variant'.

    Please refer to https://docs.gradle.org/7.0.2/userguide/validation_problems.html#ignored_annotations_on_field for more details about this problem.

希望能尽快修复,谢谢

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions