react-native - React Native - 运行 react-native run-android 时出现异步存储错误

标签 react-native react-native-android asyncstorage

我正在尝试运行 react-native run-android 但收到以下错误:

Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
D:\Work\CS\Wms-Mobile\CS-WmsMobile\node_modules\@react-native-community\async-storage\android\src\main\java\com\reactnativecommunity\asyncstorage\AsyncStorageModule.java:26: error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
                                            ^
D:\Work\CS\Wms-Mobile\CS-WmsMobile\node_modules\@react-native-community\async-storage\android\src\main\java\com\reactnativecommunity\asyncstorage\AsyncStorageModule.java:34: error: cannot find symbol     
@ReactModule(name = AsyncStorageModule.NAME)
 ^
  symbol: class ReactModule
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-community_async-storage:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 16s

    at checkExecSyncError (child_process.js:621:11)
    at execFileSync (child_process.js:639:15)
    at runOnAllDevices (D:\Work\CS\Wms-Mobile\CS-WmsMobile\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

我尝试过的事情:
  • 重新安装 node_modules
  • cd ./android 然后 ./gradlew clean

  • 但它们似乎都不起作用。很高兴听到你的建议,先谢谢你!

    我的版本:
    react-native-cli: 2.0.1
    
    react-native: 0.61.4
    
    android gradle plugin: 3.5.3
    
    gradle: 5.4.1
    
    

    最佳答案

    尝试使用以下命令

    react-native link @react-native-community/async-storage
    

    随意怀疑

    关于react-native - React Native - 运行 react-native run-android 时出现异步存储错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60510896/

    相关文章:

    reactjs - 如何隐藏和显示加载微调器 - 事件指示器 native react ,管理 Prop 和状态

    react-native - 错误 : undefined Unable to resolve module `@react-navigation/bottom-tabs`

    javascript - 如何在 React Native 的多子父 View 中将一个子垂直居中

    react-native - 当我的应用程序关闭以获取 fcm 消息时如何修复错误 "No task registered for key RNFirebaseBackgroundMessage"

    android - 如何通过 Android Studio/react native 中的 DependencyResolution 手动设置相同的版本(编译和运行时类路径)

    react-native - AsyncStorage - multiSet() 是事务性的吗?

    reactjs - 对 native 搜索使用react并滚动以点击

    react-native - React Native 中不同类型的导入?

    react-native - 等待 AsyncStorage.getItem()

    mysql - 如何在 axios 请求中将更新的设置状态值作为参数传递