【问题标题】:Where is the class "Promise" in this React-Native method example supposed to come from?这个 React-Native 方法示例中的“Promise”类应该来自哪里?
【发布时间】:2015-12-04 03:25:35
【问题描述】:

这是 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 课程?

【问题讨论】:

  • @j-doe 你能解决你的问题吗?

标签: android react-native


【解决方案1】:

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

    ...
} 

【讨论】:

    猜你喜欢
    • 2011-06-14
    • 2016-08-10
    • 2018-04-24
    • 1970-01-01
    • 2016-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-04
    相关资源
    最近更新 更多