3

与 react-native-ble-plx 链接后 react-native run-android 失败

Task :react-native-ble-plx:compileDebugJavaWithJavac FAILED

这是一个新创建的带有 react-native init 的应用程序,除了 min sdk 没有任何改变。已经尝试清理项目,将 min sdk 设置为 18,尝试使用 android studio 构建以获得更具体的错误,但仍然无法理解问题出在哪里。

我得到的错误:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
12 actionable tasks: 2 executed, 10 up-to-date
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
/Users/oriamd/Documents/MyDev/DudeWheresMyCar/node_modules/react-native-ble-plx/android/src/main/java/com/polidea/reactnativeble/converter/RxBleScanResultConverter.java:3: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
                                 ^
/Users/oriamd/Documents/MyDev/DudeWheresMyCar/node_modules/react-native-ble-plx/android/src/main/java/com/polidea/reactnativeble/wrapper/Characteristic.java:5: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
                                 ^

完整的日志在这里: https ://pastebin.com/NJAmjUJm

如果需要,可以提供更多信息。谢谢

4

2 回答 2

4

这个问题与这个问题类似。

正如@Kreator 回答中提到的,它与一些未转换为 AndroidX 的包有关。

要解决此问题,您可以使用jetifier

我在问题中提到了同样的问题,这些步骤解决了它并且应用程序再次运行。

  1. 首先,使用 Android Studio 的重构工具将您的应用重新转换:Android 开发者文档
  2. npm install --save-dev jetifier
  3. npx jetify
  4. npx react-native run-android(您的应用程序应该正确编译和工作)
  5. 在您的 package.json 的 postinstall 目标中调用npx jetifyrun (任何时候您的依赖项更新,您都必须再次 jetify)
于 2019-07-11T16:23:50.027 回答
1

问题是我使用的是 Android Studio Preview,以及 AndroidX 和更多不受支持的软件包。

于 2019-07-08T08:33:02.600 回答