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

拜拜、爱过 提交于 2019-11-27 16:01:34

问题


I am currently trying to update Android Studio to 1.0.0-RC. This seems to require gradle Android plugin 1.0.0-rc1. After the update, I started having the following error:

`Could not find property 'processManifest' on com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated@b9da89c.`

With some digging, it seems that processManifest is one of the deprecated properties that were removed in 0.14.3 version. Any idea what the new property name is? The same user guide has not been updated for the new version, so I can't find any documentation for it.

EDIT: Here is the code that needs the property. I use it to inject some build-time values into the manifest:

applicationVariants.all { variant ->
        variant.processManifest << {
            def manifestOutFile = variant.processManifest.manifestOutputFile
            def newFileContents = manifestOutFile.getText('UTF-8')
                    .replace("{GOOGLE_MAPS_KEY}", variant.buildType.ext.google_maps_key)
            manifestOutFile.write(newFileContents, 'UTF-8')
        }
    }

回答1:


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



回答2:


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.




回答3:


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!




回答4:


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.




回答5:


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.



来源:https://stackoverflow.com/questions/27302965/could-not-find-property-processmanifest-on-com-android-build-gradle-internal-a

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