So for those interested, a simple workaround for this is as follows:

   1. Replace all of the hardcoded package names for custom permissions, 
   etc (other than the root package attribute) with a tag of your own (I used "
   _PACKAGENAME_"). So for example <category 
   android:name="my.package.name.here"/> becomes <category 
   android:name="_PACKAGENAME"/>.
   2. In your build.gradle, add the following under the android scope:

applicationVariants.all { variant ->
    variant.processManifest << {
        def outFile = variant.processManifest.manifestOutputFile
        def newFileContents = 
outFile.getText('UTF-8').replace("_PACKAGENAME_", variant.packageName)
        outFile.write(newFileContents, 'UTF-8')
    }
}


On Monday, March 11, 2013 9:59:28 AM UTC-7, Robin Brandt wrote:
>
> Hello,
>
> is there a way to reference the current application's package name (not 
> the root package name for the code) at another location inside the 
> AndroidManifest.xml?
>
> More background:
>
> We're using the new gradle builder's configuration option to specify 
> different package suffixes to install multiple versions for different 
> environments (staging, production) side by side on our test devices (see 
> http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Types
> ).
>
> Our application uses the Urban Airship SDK which needs a receiver 
> configuration like this:
> <receiver
>             android:name="com.urbanairship.push.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="INSERT_APP_PACKAGE_NAME_HERE" />
>             </intent-filter>
>             ....
> </receiver>
>
> The problem is that we can't specify the package name statically as it 
> depends on the build type we're building for. Of course we could preprocess 
> the AndroidManifest.xml file but I was wondering if there was an easier way.
>
> Cheers,
> Robin
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to