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.

Manifest merge fails when building androidTest package due to missing placeholder substitution

See original GitHub issue

Describe the problem

We use detox/espresso to test our application. It builds a second application androidTest which is used alongside the main application to run grey box e2e tests.

Gradle fails processing the manifest for the test application. manifestPlaceholders substitutions are required. The main application builds fine.

We’re not using the webAuth so have both the manifestPlaceholders defined and the snippet to remove the activities in AndroidManifest

We’ve gone back to 2.8.3 for now.

What was the expected behavior?

Reproduction

Using the detox react native android example: https://github.com/wix/Detox/tree/master/examples/demo-react-native

Add auth0 as a dependency to the main project as per readme

Configure the manifestPlaceholders in app/build.gradle

As we’re not using the webAuth parts of this lib, also add the remove snippets to the AndroidManifest

      <activity
        android:name="com.auth0.react.AuthenticationActivity"
        tools:node="remove"/>
      <activity
        android:name="com.auth0.react.RedirectActivity"
        tools:node="remove"/>

Build the main app and the test app. ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release

Build will fail

node_modules/react-native-auth0/android/build/intermediates/tmp/manifest/androidTest/debug/manifestMerger7170877575298229251.xml Error:
        Attribute data@host at manifestMerger7170877575298229251.xml requires a placeholder substitution but no value for <auth0Domain> is provided.
node_modules/react-native-auth0/android/build/intermediates/tmp/manifest/androidTest/debug/manifestMerger7170877575298229251.xml Error:
        Attribute data@scheme at manifestMerger7170877575298229251.xml requires a placeholder substitution but no value for <auth0Scheme> is provided.

Environment

  • Version of this library used: 2.9.0
  • Which framework are you using, if applicable: RN 0.63.3
  • Other modules/plugins/libraries that might be involved: Detox 17.9.0
  • Any other relevant information you think would be useful: I believe it’s possible the manifestPlaceholders are not injected into android manifests for android test applications.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:22 (9 by maintainers)

github_iconTop GitHub Comments

8reactions
markparcommented, Sep 13, 2021

Good news! The method suggested in the OneSignal repo here worked! I added this section to android/build.gradle and now my Detox build is successful.

subprojects {
    afterEvaluate { subproject ->
        if (subproject.name == 'react-native-auth0') {
            def String taskRequests = getGradle().getStartParameter().getTaskRequests().toString()
            if (taskRequests.contains("assembleAndroidTest")) {
                android {
                    defaultConfig {
                        manifestPlaceholders = [auth0Domain: "E2E_TEST", auth0Scheme: "com.E2E.TEST"]
                    }
                }
            }
        }
    }
}

I verified that those placeholder values are indeed being fed through to android/app/build/intermediates/merged_manifest/debug/AndroidManifest.xml. When I build the regular version of the app, I get the “real” values from the defaultConfig section of android/app/build.gradle. When I build the Detox version, the merged manifest contains the E2E test values. 👍 I’ve updated the example repo with this change

I don’t know Gradle well enough to say if this is the “correct” solution, but it definitely works for me. Many, many thanks for your assistance, @lbalmaceda!

2reactions
raldredcommented, Sep 13, 2021

Thanks for looking into this @lbalmaceda & @markpar. I’ll add this to our maintenance window next week to try this out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gradle "manifest requires a placeholder substitution" error but ...
By declaring manifestPlaceholders twice for the same flavor/build type, your are replacing the previous one. After the previous one got replaced ...
Read more >
Manage manifest files - Android Developers
This page describes how manifest merging works and how you can apply merge preferences to resolve merge conflicts.
Read more >
Build of instrumentation test for app targeting S fails due to ...
Update the app's build.gradle so that compileSdkVersion is set to "android-S" and targetSdkVersion is set to "S". Since the app is targeting S...
Read more >
Manifest merger can't find packageName placeholder
However, manifest merger complains about the placeholder when i try to build for release buildType. It builds normally if I build for debug....
Read more >
Release Notes | Google Cloud CLI Documentation
Fixed issue where gcloud datastream create failed for Postgresql source ... When used, a Skaffold file will be generated using the Cloud Run...
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