4

Seeing issue running Instant App in Android Studio when @string value is used for host name (getting "URL not defined in the manifest" error). For example:

<data android:scheme="https" android:host="@string/SOME_DOMAIN" />

This is working fine if android:host is set to raw domain string. I can work around this by setting that value to specific domain value when running/debugging from AS but not ideal (always danger of pushing code that contains the hard coded string!)

Also, this works fine if I build/deploy base and feature apks from command line and trigger using something like adb shell am start -W -a android.intent.action.VIEW -d "<my url>"

8
  • had tried that but no luck....looks like AS requires hard coded string in android:host Oct 21, 2017 at 13:53
  • Note that this works if I build/run from command line.....it correctly interprets @string/SOME_DOMAIN ...issue is only if I run from AS Oct 21, 2017 at 14:03
  • 2
    I've filed this at issuetracker.google.com/68084954
    – dchai
    Oct 21, 2017 at 22:41
  • 1
    @JohnO'Reilly Until this is fixed, depending on your needs you can consider using manifest build variables instead.
    – Idolon
    Oct 22, 2017 at 18:09
  • @Idolon I see issue if I use manifest build variables instead. Oct 22, 2017 at 19:20

3 Answers 3

0

Maybe this is because it's not the main

Manifest.xml

, but the debug Manifest.. Try editing

app/src/main/Manifest

Note: host name matching in the Android framework is case-sensitive, unlike the formal RFC. As a result, you should always specify host names using lowercase letters.

Reference Android developer String Resources

0
0

as alternative you can use manifestPlaceholders

<data android:scheme="https" android:host="${SOME_DOMAIN} />

in you build.gradle:

flavor {
   dimension "instant"
   manifestPlaceholders = [SOME_DOMAIN: "https://instantapp.example.com/"]
}
0

The documentation is a bit unclear on whether android:host can contain a string resource, or just a simple string:

<data android:scheme="string"
      android:host="string"
      android:port="string"
      android:path="string"
      android:pathPattern="string"
      android:pathPrefix="string"
      android:mimeType="string" />

But according to Google employee @dchai:

String resources are supposed to be supported … This is a bug in Android Studio.

The bug in question has been fixed in Android Studio 3.2, so now it's possible to use string resource and manifest build variable as a value for data attributes.

1
  • String resources are supposed to be supported---Developer Console was updated to handle this case. This is a bug in Android Studio.
    – dchai
    Oct 21, 2017 at 22:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.