无法使用Gradle插件3.3覆盖清单

时间:2019-02-06 10:13:15

标签: android-studio android-manifest gradle-plugin

这基本上是我在https://github.com/insikk/Grad-CAM-tensorflow/blob/master/gradCAM_tensorflow_VGG16_demo.ipynb

中写的文本的副本

任何帮助将不胜感激:

我正在尝试将我的项目升级到带有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(没有这样的文件或目录)

我的代码与此处的代码相同-“ manifestOutputFile不再可用”下的this issue

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()

更新: 尝试了https://developer.android.com/studio/known-issues#variant_api下面的注释中建议的解决方案,并收到以下错误

  
      
  • 出了什么问题:   任务“:main:processDebugManifest”的执行失败。   找不到与以下对象匹配的构造函数:java.io.File(org.gradle.api.internal.file.DefaultProjectLayout $ DefaultDirectoryVar,java.lang.String)
  •   

2 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:0)

尝试更换

String manifestPath = "$manifestOutputDirectory/AndroidManifest.xml"

使用

String manifestPath = new File(output.processManifest.manifestOutputDirectory.get().asFile, "AndroidManifest.xml")