android - React native android 不使用 react-native-device-info 编译

标签 android reactjs react-native react-native-device-info

当我尝试使用 $ react-native run-android 构建项目时出现以下错误。

> Task :react-native-device-info:compileDebugJavaWithJavac FAILED
/Users/user/Desktop/mobile/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java:31: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
                                 ^
/Users/user/Desktop/mobile/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java:838: error: cannot find symbol
                         @Nullable Object data) {
                          ^
  symbol:   class Nullable
  location: class RNDeviceModule
Note: /Users/ammiel/Desktop/mobile/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors

FAILURE: Build failed with an exception.
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-device-info:compileReleaseJavaWithJavac'.

> Compilation failed; see the compiler error output for details.

我有 jetify 运行 postinstall 并且有

android.useAndroidX=true
android.enableJetifier=true

在我的 gradle.properties 中。

一直潜伏在许多页面/github 页面但没有成功:/任何帮助表示赞赏!

其他信息:

native react :0.59.10

react native 设备信息:5.6.1

最佳答案

我遇到了和你一样的问题!

但我设法通过添加依赖项来解决它。

yarn add react-native-device-info

沃拉!该应用程序正在运行。

关于android - React native android 不使用 react-native-device-info 编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62419195/

相关文章:

javascript - React 中的双面输入 slider

javascript - Koa 将数据从服务器传递到客户端

android - React Native - 调试适配器进程意外终止

firebase - react-native google api 限制

java - ScheduledExecutorService 行为异常

java - 在android studio中哪里可以获得笔图标按钮?

android - 如何为移动应用程序创建可集成模块

javascript - Cypress :如何在我的前端 react 应用程序和不受我控制的第 3 方 API(服务器)之间执行测试?

javascript - 如何卸载底部选项卡导航器 react 导航中的非事件屏幕?

android - 如何区分color int和color resource