Android &引用;清单中未定义URL“;运行使用@string作为主机名的即时应用程序时
当主机名使用Android &引用;清单中未定义URL“;运行使用@string作为主机名的即时应用程序时,android,android-studio-3.0,android-instant-apps,Android,Android Studio 3.0,Android Instant Apps,当主机名使用@string值时,在Android Studio中运行即时应用程序时出现问题(获取“清单中未定义URL”错误)。例如: <data android:scheme="https" android:host="@string/SOME_DOMAIN" /> 如果将android:host设置为原始域字符串,则此操作正常。当从AS运行/调试时,我可以通过将该值设置为特定的域值来解决这个问题,但这并不理想(总是有推送包含硬编码字符串的代码的危险!) 另外,如果我从命令行构
@string
值时,在Android Studio中运行即时应用程序时出现问题(获取“清单中未定义URL”错误)。例如:
<data android:scheme="https" android:host="@string/SOME_DOMAIN" />
如果将android:host
设置为原始域字符串,则此操作正常。当从AS运行/调试时,我可以通过将该值设置为特定的域值来解决这个问题,但这并不理想(总是有推送包含硬编码字符串的代码的危险!)
另外,如果我从命令行构建/部署基本的和功能APK,并使用类似于
adb shell am start-W-a android.intent.action.VIEW-d”“
的东西进行触发,这也可以正常工作。这可能是因为它不是主要的
Manifest.xml
,但调试清单。。尝试编辑
app/src/main/Manifest
注意:与正式的RFC不同,Android框架中的主机名匹配区分大小写。因此,您应该始终使用小写字母指定主机名
关于android:host
是可以包含字符串资源,还是只包含一个简单的字符串:
<data android:scheme="string"
android:host="string"
android:port="string"
android:path="string"
android:pathPattern="string"
android:pathPrefix="string"
android:mimeType="string" />
但根据谷歌员工@dchai的说法:
应该支持字符串资源…这是Android Studio中的一个bug 这个问题已经在Android Studio 3.2中修复,所以
现在可以使用字符串资源和作为
数据
属性的值。也可以使用
<data android:scheme="https" android:host="${SOME_DOMAIN} />
我试过了,但运气不好…看起来AS需要android:host中的硬编码字符串注意,如果我从命令行构建/运行,这是有效的…它正确解释了
@string/SOME_DOMAIN
…问题只有在我从ASI运行时,我才在@JohnO'Reilly上提交此文件,直到修复为止,根据您的需要,您可以考虑使用。@ IdoLon,如果我使用清单构建变量,我会看到问题。应该支持字符串资源。这是Android Studio中的一个bug。
flavor {
dimension "instant"
manifestPlaceholders = [SOME_DOMAIN: "https://instantapp.example.com/"]
}