无法使用 gradle 插件 3.3 覆盖清单 [英] Unable to overwrite the manifest with gradle plugin 3.3

查看:30
本文介绍了无法使用 gradle 插件 3.3 覆盖清单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这基本上是我在这个问题中写的文本的副本

任何帮助将不胜感激:

我正在尝试将我的项目升级到带有 gradle 4.10.1 的 gradle 插件 3.3,但我的构建失败并出现以下错误

  • 出了什么问题:任务 ':main:processDebugManifest' 执行失败.<块引用>

    java.io.FileNotFoundException:/main/property(interface org.gradle.api.file.Directory, transform(property(interface org.gradle.api.file.Directory, fixed(class org.gradle.api.internal).file.DefaultProjectLayout$FixedDirectory,/main/build))))/AndroidManifest.xml(没有那个文件或目录)

我的代码与此处的代码相同 - https://developer.android.com/studio/known-issues#variant_api 在manifestOutputFile 不再可用"下

android.applicationVariants.all { 变体 ->variant.outputs.all { 输出 ->output.processManifest.doLast {//存储到 maifest 的路径.String manifestPath = "$manifestOutputDirectory/AndroidManifest.xml"//存储清单的内容.def manifestContent = file(manifestPath).getText()...}}}

这是产生错误的行 -

def manifestContent = file(manifestPath).getText()

更新:尝试了以下评论中建议的解决方案 this answer 并得到以下错误

<块引用>
  • 出了什么问题:任务:main:processDebugManifest"执行失败.找不到匹配的构造函数:java.io.File(org.gradle.api.internal.file.DefaultProjectLayout$DefaultDirectoryVar, java.lang.String)

解决方案

def outputDir = manifestOutputDirectory文件目录如果(输出目录实例文件){目录 = 输出目录} 别的 {目录 = outputDir.get().asFile}String manifestPath = directory.toString() + "/AndroidManifest.xml"

This is basically a copy of the text that I wrote in this issue

Any help would be appreciated:

I'm trying to upgrade my project to gradle plugin 3.3 w/ gradle 4.10.1 and my build fails with the following error

  • What went wrong: Execution failed for task ':main:processDebugManifest'.

    java.io.FileNotFoundException: /main/property(interface org.gradle.api.file.Directory, transform(property(interface org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultProjectLayout$FixedDirectory, /main/build))))/AndroidManifest.xml (No such file or directory)

my code is identical to the code here - https://developer.android.com/studio/known-issues#variant_api under "manifestOutputFile is no longer available"

android.applicationVariants.all { variant ->
    variant.outputs.all { output ->
        output.processManifest.doLast {
            // Stores the path to the maifest.
            String manifestPath = "$manifestOutputDirectory/AndroidManifest.xml"
            // Stores the contents of the manifest.
            def manifestContent = file(manifestPath).getText()
...
        }
    }
}

and this is the line that produces the error -

def manifestContent = file(manifestPath).getText()

Update: tried the solution suggested in the comment below this answer and got the following error

  • What went wrong: Execution failed for task ‘:main:processDebugManifest’. Could not find matching constructor for: java.io.File(org.gradle.api.internal.file.DefaultProjectLayout$DefaultDirectoryVar, java.lang.String)

解决方案

def outputDir = manifestOutputDirectory
File directory
if (outputDir instanceof File) {
    directory = outputDir
} else {
    directory = outputDir.get().asFile
}

String manifestPath = directory.toString() + "/AndroidManifest.xml"

这篇关于无法使用 gradle 插件 3.3 覆盖清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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