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

时间:2015-12-04 03:25:35

标签: android react-native

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

@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课程?

1 个答案:

答案 0 :(得分:2)

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.+'

    ...
}