Status Update
Comments
je...@google.com <je...@google.com>
er...@gmail.com <er...@gmail.com> #3
m....@gmail.com <m....@gmail.com> #4
be...@google.com <be...@google.com>
al...@gmail.com <al...@gmail.com> #5
MacOs Sierra 10.12.6
Android Studio 2.3.3
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
as...@gmail.com <as...@gmail.com> #6
ma...@gmail.com <ma...@gmail.com> #7
There is example for use placeholder in resource file xml/shortcuts.xml. Add this to the end of your build.gradle:
// add support for placeholders in resource files
def replacePlaceholdersInFile(basePath, fileName, placeholders) {
def file = new File(basePath, fileName);
if (!file.exists()) {
logger.quiet("Unable to replace placeholders in " + file.toString() + ". File cannot be found.")
return;
}
logger.debug("Replacing placeholders in " + file.toString())
logger.debug("Placeholders: " + placeholders.toString())
def content = file.getText('UTF-8')
placeholders.each { entry ->
content = content.replaceAll("\\\$\\{${entry.key}\\}", entry.value)
}
file.write(content, 'UTF-8')
}
afterEvaluate {
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
output.processResources.doFirst {
// prepare placeholder map from manifestPlaceholders including applicationId placeholder
def placeholders = variant.mergedFlavor.manifestPlaceholders + [applicationId: variant.applicationId]
replacePlaceholdersInFile(resDir, 'xml/shortcuts.xml', placeholders)
}
}
}
}
eu...@paulo.costa.nom.br <eu...@paulo.costa.nom.br> #8
eu...@paulo.costa.nom.br <eu...@paulo.costa.nom.br> #9
I've been trying to fix it, but no success so far -- Any ideas from someone who actually understands the Android Gradle build?
Thanks!
to...@gmail.com <to...@gmail.com> #10
il...@google.com <il...@google.com>
xa...@google.com <xa...@google.com>
je...@google.com <je...@google.com>
li...@gmail.com <li...@gmail.com> #11
<data
android:host="${websiteHost}"
android:pathPattern="/app/authenticate/.*"
android:scheme="https"/>
If we want to achieve the same functionality using the new Navigation Architecture Component, we really need general support for placeholders in XML configuration files (which are used by the Navigation Architecture Component).
See also the original issue I have reported at
eu...@paulo.costa.nom.br <eu...@paulo.costa.nom.br> #12
I haven't found any adequate workaround for the lastest Gradle plugin
sp...@google.com <sp...@google.com> #13
ra...@gmail.com <ra...@gmail.com> #14
```
buildTypes {
debug {
manifestPlaceholders.deepLinkHost = "
}
...
}
```
navigation_home.xml
```
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="
xmlns:app="
xmlns:tools="
android:id="@+id/navigation_home"
app:startDestination="@id/fragment_home">
<fragment
android:id="@+id/fragment_home"
android:name="..."
tools:layout="@layout/fragment_home">
<argument
android:name="token"
android:defaultValue="@null"
app:argType="string"
app:nullable="true" />
<deepLink app:uri="${deepLinkHost}/?code={token}" />
</fragment>
```
pe...@gmail.com <pe...@gmail.com> #15
sp...@google.com <sp...@google.com> #16
ca...@gmail.com <ca...@gmail.com> #17
ni...@gmail.com <ni...@gmail.com> #18
br...@gmail.com <br...@gmail.com> #19
am...@gmail.com <am...@gmail.com> #20
eu...@paulo.costa.nom.br <eu...@paulo.costa.nom.br> #21
Unfortunately 153 stars didn't yet convince them it was a necessary feature :/
xe...@gmail.com <xe...@gmail.com> #22
mt...@gmail.com <mt...@gmail.com> #23
More info in
je...@google.com <je...@google.com>
mr...@gmail.com <mr...@gmail.com> #24
je...@google.com <je...@google.com> #25
it is currently scheduled for 7.1
mi...@gmail.com <mi...@gmail.com> #26
mr...@gmail.com <mr...@gmail.com> #27
ji...@google.com <ji...@google.com>
cm...@google.com <cm...@google.com> #28
I wonder if aapt2 macros are potentially the solution to this?
[Deleted User] <[Deleted User]> #29
That's mid-january 2022, 7.1.0 doesn't seem been published and no news about this feature since three month.
So, is there any updates for this feature and it stilled planned for next AGP version ?
br...@gmail.com <br...@gmail.com> #30
Version 7.1.0 has been released, but I don't see anything in the release notes to indicate that this issue has been addressed?
Can we get an update on this?
mt...@gmail.com <mt...@gmail.com> #31
mi...@gmail.com <mi...@gmail.com> #32
Hello,
As far as I see even with AGP 7.1.2 it is still not possible to successfully use string resources like: @string/deeplink
in the app:uri
attribute of the <deeplink>
xml element from the navigation graph file.
What can we do to make this to work?
je...@google.com <je...@google.com> #33
Scott, looks like it fell through the cracks, can you have a look at what's left to be done ?
ma...@marcardar.com <ma...@marcardar.com> #34
I'm also waiting on this.
sp...@google.com <sp...@google.com> #35
This has been fixed for deep links in navigations xml files with
The fix will be in AGP 7.3.0-alpha08.
With this fix, AGP supports manifest placeholders in deep link URI's scheme, host, and path.
Example usage:
<deepLink app:uri="${scheme}://${host}/${path}" />
Edit: not yet fully supported... see
lo...@gmail.com <lo...@gmail.com> #36
Is it only navigation files? What about other XML files?
sp...@google.com <sp...@google.com> #37
Re: #36, the fix is only for navigation files.
pe...@gmail.com <pe...@gmail.com> #38
ai...@gmail.com <ai...@gmail.com> #39
It's still an issue for shortcuts.xml, it required for targetPackage
to...@gmail.com <to...@gmail.com> #40
With manifest placeholders it doesn't always enter 'onNewIntent', and even if it does, the navController cannot recognise the deep link from the intent data's Uri, therefore the deep link is not handled.
Interestingly enough, if the trio of scheme, host and path are hardcoded, everything works as expected. For now, I'll stick with the old way, but will be open to try any new bug fixes.
sp...@google.com <sp...@google.com> #41
Re #40, what version of AGP are you using? You'll need AGP 7.3.0-alpha08 or newer for the fix mentioned in #35.
mi...@gmail.com <mi...@gmail.com> #42
sp...@google.com <sp...@google.com> #43
Re #40 and #42, can you upload a repro project and/or describe how to repro?
mi...@gmail.com <mi...@gmail.com> #44
https://${notAVariable} could be resolved correctly as a deeplink to
sp...@google.com <sp...@google.com> #45
Re #44, Ian, is there work that needs to be done on the navigation side to support manifest placeholders in URIs (#35)?
il...@google.com <il...@google.com> #46
Just like with manifest placeholders, the placeholder itself needs to be replaced at build time with the actual static value - i.e., the XML file needs to be transformed and rewritten.
The fact that placeholders were used should be totally transparent at runtime. It doesn't sound like that is actually the case?
sp...@google.com <sp...@google.com> #47
I see. Yes, I added support to use the actual static values in the AndroidManifest.xml
but not the navigation xml files... I'll address that.
Thanks for the feedback in #40, #42, and #44.
wi...@gmail.com <wi...@gmail.com> #48
I tried 7.3.0-alpha09
and the mentioned problem still persists. It recognizes the deeplink using placeholders, but it doesn't navigate where it's supposed to.
Is this already fixed in some AGP version?
sp...@google.com <sp...@google.com> #49
Re #48, no there's no fix yet
ch...@gmail.com <ch...@gmail.com> #50
ch...@gmail.com <ch...@gmail.com> #51
mi...@gmail.com <mi...@gmail.com> #52
pe...@gmail.com <pe...@gmail.com> #53
ur...@gmail.com <ur...@gmail.com> #54
po...@gmail.com <po...@gmail.com> #55
How to use nav graph in production apps without this feature?
I hope no one answers by duplicating code and files.
je...@google.com <je...@google.com>
mi...@google.com <mi...@google.com>
mi...@gmail.com <mi...@gmail.com> #56
mi...@google.com <mi...@google.com> #57
Hi, I am currently working on a fix for navigation placeholders. Aiming for the fix to be in the next release of AGP.
al...@gmail.com <al...@gmail.com> #58
mi...@google.com <mi...@google.com> #59
Hello, this has not been released yet. Apologies for the delay- we are currently in discussion about the design of placeholders and there are still more decisions to be made to best support this and expand on it in the future. I will update here with any updates as soon as they are available.
j....@gmail.com <j....@gmail.com> #60
Are you considering adding support to all XML files inside /res folder?
mi...@google.com <mi...@google.com> #61
Right now, we are only considering navigation files. However, it is possible this is expanded to other xml files in the future.
ag...@digibank.co.il <ag...@digibank.co.il> #62
Can't wait for that :)
mi...@gmail.com <mi...@gmail.com> #63
rp...@gmail.com <rp...@gmail.com> #64
ik...@gmail.com <ik...@gmail.com> #65
any updates?
Description
The latest release of the Android Gradle Plugin (0.10.0) added support for placeholders in the Android Manifest, like ${packageName}. This is very useful when working with different build types and product flavors.
It yould be nice to extend this feature to the various XML configuration files as well.
In my case, I would like to set the 'android:searchSuggestAuthority' attribute, from the Search widget in the ActionBar, based on the package name.