Manifest Placeholders error in unit tests after updating to Gradle 4.2.0

Viewed 756

After updating 'com.android.tools.build:gradle' from version 4.1.3 to 4.2.0, I started to get an error that 'manifestPlaceholders' are no longer merged into the manifest when running unit tests. Everything works fine when I run the app. It just fails when running tests.

defaultConfig {
    (...)
    manifestPlaceholders = [
            myPlaceholder1: "some_value_1",
            myPlaceholder2: "some_value_2"
    ]
}

Any unit test in the "test" folder now fails with this message:

> Task :myLib:processDebugUnitTestManifest FAILED
/myProject/source/android/myProject/build/intermediates/tmp/manifest/test/debug/manifestMerger684952061703372993.xml Error:
    Attribute attribute1 at manifestMerger684952061703372993.xml requires a placeholder substitution but no value for <myPlaceholder1> is provided.
/myProject/source/android/myProject/build/intermediates/tmp/manifest/test/debug/manifestMerger684952061703372993.xml Error:
    Attribute attribute2 at manifestMerger684952061703372993.xml requires a placeholder substitution but no value for <myPlaceholder2> is provided.

I had to downgrade again to version 4.1.3. Anyone has any solution for this?

1 Answers

This is a specific work around here, as my issues stemmed from the required manifestPlaceHolders for the Auth0 library. I was able to work around the manifest merger issue on the unit tests build by adding a manifest to each modules unit test directory (not AndroidTest directory). The manifest I used just disabled the need for the placeholders by removing the activities that required it:

https://github.com/openid/AppAuth-Android/blob/master/library/javatests/AndroidManifest.xml

Perhaps if that manifest doesn't work for you could add the placeholders directly to the manifest in the unit test directory. I didn't try this but that might be a path forward.

Related