无法使用Gradle插件3.3覆盖清单 [英] Unable to overwrite the manifest with gradle plugin 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 ->
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()
...
}
}
}
这是产生错误的行-
def manifestContent = file(manifestPath).getText()
更新: 尝试了此答案下面的注释中建议的解决方案,并得到了以下错误
- 出了什么问题: 任务:main:processDebugManifest"的执行失败. 找不到与以下对象匹配的构造函数: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"
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屋!