Could not get unknown property 'manifestOutputDirectory'

Viewed 10559

I'm trying to "make project" with Android Studio, and I'm getting this error:

Execution failed for task ':myApp:processGoogleDebugManifest'.

Could not get unknown property 'manifestOutputDirectory' for task ':myApp:processGoogleDebugManifest' of type com.android.build.gradle.tasks.ProcessMultiApkApplicationManifest.

Any help please?

EDIT: This error occurred after I updated to gradle v6.5 and plugin v4.1.0. If I revert to gradle v6.1.1 and plugin v4.0.0 the error disappears.

5 Answers

I encountered this same issue today, in my case it was caused by an outdated version of Huawei's AG Connect plugin. I was using com.huawei.agconnect:agcp:1.2.1.301, but when I updated it to com.huawei.agconnect:agcp:1.4.1.300 the issue was fixed.

But if Huawei's plugin is not the problem you are having, you can debug the issue by running gradle with --stacktrace option to see where the issue originates from. In Android Studio you can add command line options for gradle in Settings/Build, Execution, Deployment/Compiler/Command-line options.

If you're using bugsnag, replace the following line

classpath 'com.bugsnag:bugsnag-android-gradle-plugin:4.+'

with:

classpath 'com.bugsnag:bugsnag-android-gradle-plugin:5.+'

For further detail, see this issue: Fails with AGP 4.1.0-alpha04 and this comment.

I write it here because this solution saved my day :

We can fix this by simply replacing references to

manifestOutputDirectory

by

multiApkManifestOutputDirectory
enter code here

in your gradle tasks

For example :

android.applicationVariants.all { variant ->
    variant.outputs.all { output ->
        output.processManifest.doLast { task ->
            def outputDir = multiApkManifestOutputDirectory.asFile.get()
            String manifestMergerpath = "$outputDir/AndroidManifest.xml"
            writeManifest(manifestMergerpath, placeholders)
        }
    }
}  
android.applicationVariants.all {
    outputs.all {
        processManifestProvider.configure {
            val multiApkManifestOutputDirectory = (this as ProcessMultiApkApplicationManifest)
                .multiApkManifestOutputDirectory // 
            doLast {
                multiApkManifestOutputDirectory.get()
                    .asFile
                    .walkTopDown()
                    .forEach { 
                        
                    }
            }
        }
    }
}
Related