Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Setting a string in APL.xml file


I am slowly trying to develop an android plugin and need some help about how you insert a variable into a string in the ___APL.xml file.

I am trying to add this permission

 <uses-permission android:name="$S(PackageName).permission.C2D_MESSAGE"/> 

where $S(PackageName) is defined at the top as

 <setStringFromProperty result="PackageName" ini="Engine" section="/Script/AndroidRuntimeSettings.AndroidRuntimeSettings" property="PackageName" default=""/>

can someone tell me the correct way i would get the variable to be replaced by the package name and not $S(PackageName).


Product Version: UE 4.10
more ▼

asked Feb 12 '16 at 07:40 PM in Packaging & Deployment

avatar image

28 3 6 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hi gaz99,

Ok, a few things to look at here. Normally you'd use < addPermission /> for this, but it copies all the attributes exactly into a < use-permission /> tag if the name isn't already in the manifest. Since you want a string replacement this won't work, but there is another way to do this using element variables to make up the element.

The second issue is your way of getting the package name will work only if an exact package name is entered and doesn't use the [PROJECT] replacement. We can work around this as well by reading the package attribute from the manifest instead. This needs to be in the < androidManifestUpdates /> section, not < init />.

   <setStringFromAttribute result="PackageName" tag="manifest" name="package" />
   <setElement result="mypermission" xml='<uses-permission android:name="$S(PackageName).permission.C2D_MESSAGE"/>' />
   <addElement tag="manifest" name="mypermission" />
more ▼

answered Feb 15 '16 at 06:36 PM

avatar image

Chris Babcock STAFF
1k 11 110 35

avatar image gaz99 Feb 18 '16 at 05:17 PM

Hi Chris,

I've tried your suggestion however when launching to a device i get this message in the output log

  Missing element variable 'manifest' in 'addElement tag="manifest" name="mypermission"' (skipping instruction)
avatar image Chris Babcock STAFF Feb 18 '16 at 10:02 PM

I've looked at the message and the 'manifest' missing is a bug; it wrote the tag instead of the name in this case. The actual error is it didn't find 'mypermission' as an element variable. This is due to the parse failing for a few reasons. The first issue is the needed to be &lt; and &gt;. The second is with the android:name not having android defined in the element. There is a way around this by using the < addAttribute /> since I deal with the namespace there. I just tried this and it works:

         <setStringFromAttribute result="PackageName" tag="manifest" name="package"/>
         <setElement result="mypermission" xml="&lt;uses-permission/&gt;"/>
         <addAttribute tag="$mypermission" name="android:name" value="$S(PackageName).permission.C2D_MESSAGE"/>
         <addElement tag="manifest" name="mypermission"/>

This creates an empty element then adds the attribute to it, then adds it to the manifest.

avatar image gaz99 Feb 21 '16 at 03:31 PM

Thanks for your help Chris all is working now :-)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question