Could not find property 'processManifest' on com.android.build.gradle.internal.api.ApplicationVariantImpl

折月煮酒 提交于 2019-11-29 01:17:34

According to the documentation for APK splits (http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits) this method has moved into VariantOutput (available via variant.outputs):

Deprecation Warning: the current variant API contains some methods that have moved under its outputs. The method are still there, but will fail if there are 2+ outputs. They will be completely removed in 1.0 These are:

  • get/setOutputFile
  • getProcessResources
  • getProcessManifest
  • getPackageApplication/Library
  • getZipAlign

Additional methods on VariantOutput

  • String getAbiFilter()
  • String getDensityFilter()
  • Task getAssemble()
  • String getName()
  • String getBaseName()
  • String getDirName
  • set/getVersionOverride // optional versionCode override
  • int getVersionCode() // returns either the versionCode override from the output or the versionCode from the variant itself

I got this error as well after updating to Android Studio 1.0.0 on the Beta Channel. However, I could not find any reference in my own gradle files to processManifest. After some searching, I realized that I needed a new Robolectric gradle plugin:

https://github.com/robolectric/robolectric-gradle-plugin/releases

Using version 0.14.0 of the Robolectric Gradle Plugin (and version 2.4 of Robolectric) has resolved the error for me.

I have not been able to find a solution to the problem, but simply a workaround. Android Gradle plugin Version 0.11 introduces a new API called Manifest merger. It allows to achieve the same thing that my hack allowed me to do.

Here are the changes needed:

  • Surround any variable that you inject in your manifest with "${GOOGLE_MAPS_KEY}"
  • Define a manifestPlaceholders map in each BuildType. That is:

    buildTypes {
        debug {
            manifestPlaceholders = [GOOGLE_MAPS_KEY: "xxxxxxxxxxxxxxxxxxxx"]
        }
        release {
            manifestPlaceholders = [GOOGLE_MAPS_KEY: "xxxxxxxxxxxxxxxxxxxx"]
        }
     }
    

That's it! The plugin will automatically replace those variables in your Manifest. Pretty neat!

vfs1234
android.applicationVariants.all{ variant ->
variant.outputs.each { output ->
    output.processManifest.doLast{ 
    def manifestFile = output.processManifest.manifestOutputFile
    def updatedContent =manifestFile.getText('UTF-8').replaceAll("UMENG_CHANNEL_VALUE", "${variant.productFlavors[0].name}")
    manifestFile.write(updatedContent, 'UTF-8')
    }
}

}

I changed it in this way, which just add a new layer outside the older one. This works because processManifest is now in the outputs field. Think this could be helpful.

In my case I was getting this error because there was a dependency on a library folder specified in my settings.gradle. That folder had a lot of faulty configurations apparently. So as soon as I removed it from settings.gradle, the project compiled just fine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!