如何解决React Native Android - 没有方法签名
我浏览了有关 SO 的相关帖子,并查看了已接受的答案和建议。不幸的是,它们要么不适用,要么在我的情况下不起作用。
build.gradle
看起来像这样:
...
def getHostUrl = { ->
def host = project.hasProperty('hostUrl') ? hostUrl : "default.example.com"
println "host is set to $host"
return host
}
...
android {
defaultConfig {
hostUrl getHostUrl()
}
productFlavors{
def config = signingConfigs.release
Snapshot {
hostUrl getHostUrl()
}
AutomatedBuild {
hostUrl getHostUrl()
}
}
}
我省略了不相关的细节。
AndroidManifest 对应的代码如下:
<activity>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.broWSABLE" />
<data
android:host="${hostUrl}"
android:scheme="https" />
</intent-filter>
</activity>
打印 getHostUrl()
方法中的日志。我得到的错误如下:
FAILURE: Build Failed with an exception.
* Where:
Build file '/Users/../android/app/build.gradle' line: 247
* What went wrong:
A problem occurred evaluating project ':app'.
> No signature of method: build_o4dxxns0hz91cl99sptfb0zi.android() is applicable for argument types: (build_o4dxxns0hz91cl99sptfb0zi$_run_closure17) values: [build_o4dxxns0hz91cl99sptfb0zi$_run_closure17@6d175f63]
build.gradle>Line 247
是起始标签 android {
,这意味着这个标签有问题。我尝试删除 hostUrl getHostUrl()
& hostUrl getHostUrl()
但这会导致 ManifestMerger 错误,其中 AndroidManifest 没有获得 ${hostUrl}
的值。
如果我在 <data android:host
中使用硬编码值,应用程序能够按预期处理深层链接。但是要求是使用项目属性通过Fastfile脚本设置host。
我希望我提供了足够的信息。我是 React Native 的新手,因此感谢任何帮助。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。