不推荐使用RegisterResGeneratingTask,请使用registerGeneratedFolders(FileCollection) [英] RegisterResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)

查看:1211
本文介绍了不推荐使用RegisterResGeneratingTask,请使用registerGeneratedFolders(FileCollection)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用具有新的3.0.0 Gradle插件的新android studio.
生成警告时:

Using new android studio with new 3.0.0 Gradle pluging.
When building some warning happened:

registerResGeneratingTask is deprecated, use
registerGeneratedFolders(FileCollection)

推荐答案

据我所知,添加为类路径依赖项的插件会带来问题. IE. Firebase 遇到了问题. 勺子此Google搜索会发现很多GitHub存储库,并提出了一个问题同样的事情,它们的共同点在于,这是一个Gradle插件.正如伴侣 *

From what I can tell, plugins added as classpath dependencies will give problems. I.e. Firebase had an issue with it. Spoon and Flutter as well. Doing this Google search reveals a lot of GitHub repos with an issue raised over the same thing, and all they have in common is the fact that it's a Gradle plugin. Fabric appears to be a cause as well, as mentioned by Mate*

据我所知,问题出在一个或多个Gradle插件上.它也可以由您的Gradle代码触发,但是如果您的项目是应用程序而不是Gradle插件,则很可能不适用.

From what I can tell, the issue comes from a/multiple Gradle plugin (s). It can also be triggered by your Gradle code, but this is most likely not applicable if your project is an app and not a Gradle plugin.

正如 Alex Cohn 在评论中所述,过时是一种警告.在这种情况下,这意味着它将最终被删除.因此,就目前而言,假设它是一个插件(而不是您自己制造),则可以忽略它.在删除时,大多数/所有主要插件都应进行更新以修复它.

And as mentioned by Alex Cohn in a comment, deprecation is a warning. In this case, it means it's a feature that's going to be removed eventually. So for now, assuming it is a plugin (and not made by you), you can ignore it. By the time it's removed, most/all of the major plugins should be updated to fix it.

再次,这是警告; 不是错误.您仍然可以运行它,如果对此问题无能为力,请忽略它.禁用例如Fabric *插件过大,因为它仍然可以正常工作.

And, again, it is a warning; not an error. You can still run it, and ignore it if there's nothing you can do about the issue. Disabling e.g. the Fabric* plugin is overkill, as it still works.

我自己不使用Fabric,Fabric不是开源的,所以我不知道开发人员是否修复了它

TL; DR:是Gradle插件引起的.这是一个警告(不是错误),因此删除导致该问题的插件是多余的.如果您无法修复它,只要暂时不使用它(不删除它)就不要管它

TL;DR: Gradle plugins are the cause. It's a warning (not an error), so removing the plugins that cause the issue is overkill. If you can't fix it, leave it alone as long as it is only deprecated at the moment (not removed)

如果您使用Firebase,则在迁移指南中也有针对它的特定解决方案(本文稍后链接);排除番石榴模块

If you use Firebase, there is a specific solution to it that's also mentioned in the migration guide (linked later in this post); exclude the guava module

classpath ('com.google.firebase:firebase-plugins:1.1.0') {
    exclude group: 'com.google.guava', module: 'guava-jdk5'
}


问题本身很难发现.据我所知,在我检查过(并在此答案中链接过)的所有插件中,没有一个导致它的单一问题.如果您编写了导致该问题的代码(可以解决该问题;添加第三方gradle插件不会导致该问题),则可以尝试一些方法来解决它.


The issue itself is fairly hard to detect. From what I can tell, there is no single issue that causes it in all of the plugins I checked (and linked in this answer). If you have coded something that causes the issue (and it's possible to fix it; adding a 3rd party gradle plugin isn't causing it), there are some things you can try to fix it.

据我所知,通过遵循Gradle插件3.0中的主题,通过更新Gradle文件(尽管在Spoon库中,已通过更改与TestVariant相关的行进行了修复)解决了该问题. .0迁移指南.

From what I can tell as of the actual cause, it's solved by updating the Gradle file (though in the Spoon library, it was fixed by changing a line related to TestVariant) by following the topics in the Gradle plugin 3.0.0 migration guide.

开发人员文档,但是根据存在问题的项目上的拉取请求,以下是我认为与之相关的一些东西:

The entire thing is covered by the developer docs, but here's some of the stuff I think is relevant based on the pull requests done on projects where it's been a problem:

除了更新Gradle版本和插件外,还需要在repositories下添加google()存储库.

Aside updating the Gradle version and plugin, you also need to add the google() repo under repositories.

compile现在是implementationapi,但推荐使用implementation.

compile is now implementation or api, but implementation is the recommended one.

providedcompileOnlyapkruntimeOnly

androidTestCompile已变为androidTestImplementation,并且testCompile-> testImplementation

androidTestCompile has become androidTestImplementation, and testCompile -> testImplementation

如果使用调味料,则必须使用调味料尺寸(由文档覆盖).

If you use flavors, you have to use flavor dimensions (covered by the docs).

对于构建类型,如果有一个库没有该构建类型,则必须包括回退.这些在android块下的profile块中定义.

For build types, you have to include fallbacks in case there is a library that doesn't have that build type. These are defined in the profile block under the android block.

如果尚未完成,则必须首先定义gradle插件.如果您没有任何其他类路径依赖关系,那不是问题.但是,如果这样做,请确保首先定义gradle插件.

If not done already, the gradle plugin has to be defined first. If you don't have any other classpath dependencies, it isn't a problem. But if you do, make sure the gradle plugin is defined first.

如果您使用testVariants,请确保不要在该类中调用testedVariant.这似乎是Spoon库的原因.

If you use testVariants, make sure you don't call testedVariant in the class. It appears to be the cause for the Spoon library.

根据我的判断,这些都是为解决此问题而进行的一些更改.

These things are, from what I have been able to tell, some of the changes that were made to fix the issue.

这篇关于不推荐使用RegisterResGeneratingTask,请使用registerGeneratedFolders(FileCollection)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆