首页 > 解决方案 > 升级 react native 项目后使用 Kotlin @react-native-community/async-storage 仍然继续搜索 MainApplication.java 文件

问题描述

我有工作反应原生 android 应用程序。我已经更新了项目以在其中使用 Kotlin。但@react-native-community/async-storage 仍在寻找 MainApplication.java

要更新项目以使用 kotlin,我使用了本手册 https://levelup.gitconnected.com/powering-react-native-with-kotlin-swift-support-e5c1210a4e25

Z:\....\AlarmMobile>react-native link @react-native-community/async-storage
warn Calling react-native link [packageName] is deprecated in favor of autolinking. It will be removed in the next major release.
Autolinking documentation: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
(node:14176) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
info iOS module "@react-native-community/async-storage" is already linked
info Linking "@react-native-community/async-storage" Android dependency
error Linking "@react-native-community/async-storage" failed.
Error: ENOENT: no such file or directory, open 'Z:\...\android\app\src\main\java\com\alarmmobile\MainApplication.java'
    at Object.openSync (fs.js:498:3)
    at Object.readFileSync (fs.js:394:35)
    at applyPatch (Z:\...\node_modules\@react-native-community\cli-platform-android\build\link\patches\applyPatch.js:42:51)
    at Object.registerNativeAndroidModule [as register] (Z:\...\node_modules\@react-native-community\cli-platform-android\build\link\regi
sterNativeModule.js:34:27)
    at Z:\...\node_modules\react-native\node_modules\@react-native-community\cli\build\commands\link\linkDependency.js:63:16
    at Array.forEach (<anonymous>)
    at linkDependency (Z:\...\node_modules\react-native\node_modules\@react-native-community\cli\build\commands\link\linkDependency.js:36
:32)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Object.link [as func] (Z:\...\node_modules\react-native\node_modules\@react-native-community\cli\build\commands\link\link.js
:110:5)
    at async Command.handleAction (Z:\...\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:186:9)
info Run CLI with --verbose flag for more details.

标签: androidreact-nativekotlin

解决方案


推荐阅读