question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't build unit tests after upgrade to AGP 4.2

See original GitHub issue

Android Studio 4.2.1 AGP 4.2.1 Gradle 6.7.1 AppAuth 0.8.1.1

After upgrade to AGP 4.2.1 I’m getting error Manifest merger failed : Attribute data@scheme at manifestMerger17575735412594745234.xml requires a placeholder substitution but no value for <appAuthRedirectScheme> is provided. when I’m trying build unit tests. For normal build it’s working. I have multi-module project and in my app module, there is AndroidManifest.xml:

<activity
    android:name="net.openid.appauth.RedirectUriReceiverActivity"
    tools:node="replace">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data
            android:host="identity"
            android:scheme="xxx" />
    </intent-filter>
</activity>

In AppAuth module, there is test/AndroidManifest.xml:

<activity
    android:name="net.openid.appauth.RedirectUriReceiverActivity"
    tools:node="replace" />

And in build.gradle (app) I have:

unitTestVariants.all {
    it.mergedFlavor.manifestPlaceholders += [
            appAuthRedirectScheme: "xxx"
    ]
}

It worked fine until the upgrade. Probably “unitTestVariants” stopped working? Is there any alternative way?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:11

github_iconTop GitHub Comments

2reactions
MichalKlusakcommented, Jul 9, 2021

@agologan I didn’t even need to add it to tests. In <module>/src/AndroidManifest.xml it is enough. test and AndroidTest use it as fallback. @vramasam The point is that we want every module except the main module (app module) don’t see appAuthRedirectScheme so when we have for example this module hierarchy

                                   app
                                    |
                           ______________________________________
                            |                        |         |
                            A                        B         C
                            |                        |         
                       _____________              AppAuth
                       |           |
                       D           E
                                   |
                                AppAuth

we have to add empty replacement to modules B and E so every module above them (for example A) get empty RedirectUriReceiverActivity in manifest merger and only in app module add AndroidManifest with final android:host and android:scheme.

0reactions
agologancommented, Dec 13, 2021

Closing this as there has been no response from the OP in a reasonable amount of time. Assuming issue has been resolved. Feel free to open a new issue if you require further assistance 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrade to AGP 4.2.0 ,unable to generate Jacoco code ...
I was having the same problem after upgrading to 4.2.1. It looks like the Jacoco execution data file for non-instrumented unit tests has ......
Read more >
Known issues with Android Studio and Android Gradle Plugin
Workaround 1: Run the Gradle check task from the IDE rather than running a unit test. Workaround 2: Update your build script to...
Read more >
AGP 7.0.0 does not create unit test jacoco exec files correctly ...
The first comment in this issue #1 perfectly describes the issue: the coverage file is literally empty. Again: I only see this happening...
Read more >
Upgrading your build from Gradle 7.x to the latest
For example, build scripts that previously added Test Suite dependencies with the ... Dependency): Unit defined in org.gradle.kotlin.dsl public operator fun ...
Read more >
AGP 7.0: Next major release for the Android Gradle plugin
In fact, in AGP 4.2 some of these APIs have changed. ... to allow separate blocks for UnitTests ( beforeUnitTest and unitTest )...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found