Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android.defaultConfig.manifestPlaceholders must be placed in all modules #325

Closed
julien-baczynski opened this issue Mar 27, 2018 · 3 comments
Labels
manifest Issues that are affected by manifest definitions / merging / placeholders question

Comments

@julien-baczynski
Copy link

Hi,

I'm using AppAuth in a low level module :
App module
|
Networking module (use AppAuth to encapsulate api calls)
|
Module containing AppAuth helper classes

I intended to reuse the third module in other apps, and by doing so, configure the redirect url in
the app module grade file.
But it won't let me build my app until i put a dummy manifest placeholder in every module gradle file.

Am i missing something or making a wrong usage of the library?

Thanks

@iainmcgin
Copy link
Member

You're not doing anything wrong, it's just manifest placeholders don't seem to work very well when chained through more than one layer of indirection. My suggestion would be to remove the activity definition for RedirectUriReceiverActivity in your intermediary module. See Google's documentation on manifest merging for more info; essentially you would add the following definition to your intermediary module's AndroidManifest.xml:

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

This would then mean each app module would need to explicitly define the activity definition for RedirectUriReceiverActivity, with their own settings. Alternatively, you could define your own manifest placeholder, "myPlaceholder":

<activity android:name="net.openid.appauth.RedirectUriReceiverActivity" 
          android:exported="true" 
          tools:node="merge">
    <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:scheme="${myPlaceholder}"/>
    </intent-filter>
</activity>

This just pushes the placeholder up a layer, but that might be sufficient for you.

@iainmcgin iainmcgin added question manifest Issues that are affected by manifest definitions / merging / placeholders labels Apr 4, 2018
@chiara-jm
Copy link

chiara-jm commented Jun 5, 2019

Hi @iainmcgin , I know this issue is closed but I am facing a similar problem. I have the same setup as @julien-baczynski but my problem is while running unit test on the intermediate module, it fails cause the manifest merger expects the placeholder.

Is there a way to avoid enforcing the manifestPalceholder and configure it programatically

I see it both equally intrusive in the intermediate module to add:

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

on your manifest than or

    defaultConfig {
        manifestPlaceholders = ['appAuthRedirectScheme': ""]
    }

on your gradle

Thanks for the help

@ignaciotcrespo
Copy link

ignaciotcrespo commented Jun 20, 2019

nice tip using the tools:node, thanks @iainmcgin @chiara-jm

In my case I prefer to use a string for configuration, so my activity is:

        <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:scheme="@string/my_redirect_scheme" />
            </intent-filter>
        </activity>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
manifest Issues that are affected by manifest definitions / merging / placeholders question
Projects
None yet
Development

No branches or pull requests

4 participants