Reputation: 2079
I want to open an activity on link click (show action chooser with app name). All works fine, action chooser is shown with my app, but only if I do not use property name in manifestPlaceholder, else default browser opens (without any errors).
I have this lines in gradle.properties file:
HOST_NAME_DEV="dev.mysite.com"
HOST_NAME_PROD="mysite.com"
I want to create a manifestPlaceholder like this:
// in manifest
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="${host}"
android:scheme="https" />
</intent-filter>
//in build.gradle
productFlavors {
production {
manifestPlaceholders = [host: HOST_NAME_PROD]
}
develop {
manifestPlaceholders = [host: HOST_NAME_DEV]
}
}
And it does not work.
But if I paste string into the manifestPlaceholder all works fine:
productFlavors {
production {
manifestPlaceholders = [host: "mysite.com"]
}
develop {
manifestPlaceholders = [host: "dev.mysite.com"]
}
}
In this way all works fine too:
productFlavors {
production {
resValue "string", "host", HOST_NAME_PROD
}
develop {
resValue "string", "host", HOST_NAME_DEV
}
}
// and in manifest
android:host="@string/host"
But I want to use manifestPlaceholders.
What I do wrong?
Upvotes: 2
Views: 3327
Reputation: 24039
I had this same issue with the double quotes when using buildConfigField
to replace manifestPlaceholders
. Annoyingly this did not cause compile issue only found in runtime. Buildconfigfields require the quotes for them to be rendered as a valid Java String.
Before:
properties file
config.AUTH_DOMAIN = "\"myDomain\""
build.gradle
def authDomain = config.AUTH_DOMAIN
android{
defaultConfig{
buildConfigField("String", "AUTH_DOMAIN", "$authDomain")
manifestPlaceholders = [authDomain: authDomain]
}
}
Manifest: <data android:host=""myDomain"" />
After:
properties file (removed extra the quotes)
config.AUTH_DOMAIN = "myDomain"
build.gradle
def authDomain = config.AUTH_DOMAIN
android{
defaultConfig{
//add the quotes or buildConfigField won't compile
buildConfigField("String", "AUTH_DOMAIN", "\"$authDomain\"")
manifestPlaceholders = [authDomain: authDomain]
}
}
Manifest: <data android:host="myDomain" />
Upvotes: 0
Reputation: 333
Problem: Data injecting with "(Double Quotes) in your manifest.
Solution: Remove "(Double Quotes) from your values of gradle.properties that it. Just like this:
HOST_NAME_DEV=dev.mysite.com
HOST_NAME_PROD=mysite.com
Upvotes: 7