当我尝试使用 $ 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/