Inject parent application id into library AndroidManifest components

829 views
Skip to first unread message

Ryan Lepinski

unread,
Jul 1, 2014, 12:11:11 PM7/1/14
to adt...@googlegroups.com
Hi,

In an android library's manifest file, if I try to use the the built in placeholder "applicationId" in the manifest it injects the package name of the library instead of the package name of the parent application.

Example library manifest:

<?xml version="1.0" encoding="utf-8"?>
          android:versionCode="1"
          package="com.example.what"
          android:versionName="1.0">

    <application>

        <receiver
            android:name=".GCMPushReceiver"
            android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
                <action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
                <category android:name="${applicationId}"/>
            </intent-filter>
        </receiver>

        <receiver
            android:name=".ADMPushReceiver"
            android:permission="com.amazon.device.messaging.permission.SEND">
            <intent-filter>
                <action android:name="com.amazon.device.messaging.intent.RECEIVE"/>
                <action android:name="com.amazon.device.messaging.intent.REGISTRATION"/>
                <category android:name="${applicationId}"/>
            </intent-filter>
        </receiver>
    </application>

</manifest>


Will replace all instances of ${applicationId} as com.example.what instead of the parent application. If I try to add a custom placeholder value and define in the parent applications build.gradle it results in a build error: Manifest merger failed : Attribute category#${parentApplicationId}@name at AndroidManifest.xml:46:27 requires a placeholder substitution but no value for <parentApplicationId> is provided.


Is there a way to work around this other than having the parent application define the elements in its own manifest? It would be very helpful to allow the library manifests to be automatically configured in the parent application.

Thanks,
Ryan

James Wald

unread,
Jul 28, 2014, 5:51:00 PM7/28/14
to adt...@googlegroups.com
I'm experiencing the same issue here with Android Gradle plugin 0.12.2. The final application manifest has the library project's "local" applicationId instead of the app project's applicationId. I thought this was the purpose of substitutions such as ${applicationId}?

Claus Holst

unread,
Sep 14, 2014, 2:03:04 PM9/14/14
to adt...@googlegroups.com
Hi Ryan,

Exact description of my issue!

The documentation states; "After the last file merging occurred, and before the resulting merged android manifest file is written out, all values with a placeholder will be swapped with injected values."

So my thought was also that the library manifest would get the placeholder values from either the parent application and even flavors of the parent app.

Can I use your description to file an issue with the AOSP issue tracker (https://code.google.com/p/android/issues) ?

Regards,
Claus
Reply all
Reply to author
Forward
0 new messages