gpt4 book ai didi

android - 这个 React-Native 方法示例中的类 "Promise"应该来自哪里?

转载 作者:行者123 更新时间:2023-11-29 20:15:01 26 4
gpt4 key购买 nike

这是 React-Native Android 文档中使用 Native 模块(java 类)实现 promise 的示例:

@ReactMethod
public void measureLayout(
int tag,
int ancestorTag,
Promise promise)

https://facebook.github.io/react-native/docs/native-modules-android.html#content

我收到指向 Promise 的错误“找不到符号”,而 Android API 似乎没有任何可导入的内容。我应该在哪里/如何获得 Promise 类(class)?

最佳答案

Promise 类是从 com.facebook.react.bridge 包中导入的。

它是在 react-native 0.15 中添加的,因此请确保 android/app/build.gradle 编译的版本 > 0.15。

比如我的是:

...

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.facebook.react:react-native:0.15.+'

...
}

关于android - 这个 React-Native 方法示例中的类 "Promise"应该来自哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34080409/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com