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 (将#修改为@)