Reputation: 41
FAILURE: Build failed with an exception.
Could not find method getMetadataByConfig() for arguments [] on task ':app:processDebugManifest' of type com.android.build.gradle.tasks.ProcessMultiApkApplicationManifest.
Upvotes: 4
Views: 1411
Reputation: 168
I ran into this issue recently while trying to upgrade our project's Gradle to 8.4 and AGP to 8.1.2, and here's what I did.
agcp
version(currently 1.9.1.301)build.gradle
file of app module according to this postagcp{
manifest = false
}
Besides, this plugin will enable a APM tool by default, you can disable it by adding apmsInstrumentationEnabled=false
to your project's gradle.properties
file
Upvotes: 3
Reputation: 1
I commented out one line in gradle.properties:
#org.gradle.unsafe.configuration-cache=true
This helped me.
Upvotes: 0
Reputation: 2099
If you are using Gradle's Configuration Cache and Huawei's AgConnect plugin at the same time, then the problem might be due to this plugin. See: https://forums.developer.huawei.com/forumPortal/en/topic/0202743615441540593
As a temporary solution until plugin maintainers fix the plugin, consider disabling Gradle's Configuration Cache or applying AgConnect plugin conditionally. For example don't apply it during development and only apply it while releasing.
Here is some sample code to apply the plugin conditionally. All code in Kotlin (kts). Helper functions:
fun Project.isReleaseTask(): Boolean =
gradle.startParameter.taskRequests.toString().toLowerCase().contains("release")
fun Project.isPublishTask(): Boolean =
gradle.startParameter.taskRequests.toString().toLowerCase().contains("publish")
val Project.isHuaweiPluginEnabled: Boolean
get() = properties["com.yourcompany.enableHuaweiPlugin]?.toString().toBoolean()
Then, If you have a convention plugin:
class MyConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
maybeApplyHuaweiPlugin()
// other configurations
}
private fun Project.maybeApplyHuaweiPlugin() {
if (isHuaweiPluginEnabled || isReleaseTask() || isPublishTask()) {
pluginManager.apply("com.huawei.agconnect")
}
}
}
OR: if you don't have convention plugin:
app/build.gradle.kts
plugins {
id("com.android.application")
id("com.huawei.agconnect") apply false
}
if (isHuaweiPluginEnabled || isReleaseTask() || isPublishTask()) {
pluginManager.apply("com.huawei.agconnect")
}
Upvotes: 2