gpt4 book ai didi

cordova - ionic - 添加插件失败,因为它已经存在,删除插件失败,因为它不存在

转载 作者:行者123 更新时间:2023-12-02 16:42:11 27 4
gpt4 key购买 nike

我知道如何搞乱我的 Ionic 项目...一些帮助将不胜感激。

我正在尝试添加cordova-plugin-camera,所以我正在做的是:

$ cordova plugin add cordova-plugin-camera 这会返回错误:

Installing "cordova-plugin-camera" for android
Android Studio project detected
Error during processing of action! Attempting to revert...
Failed to install 'cordova-plugin-camera': CordovaError: Uh oh!
"C:\xampp\htdocs\project x\anonymous-social\platforms\android\app\src\main\res\xml\camera_provider_paths.xml" already exists!
at copyNewFile (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\lib\pluginHandlers.js:261:45)
at install (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\lib\pluginHandlers.js:51:17)
at ActionStack.process (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\cordova-common\src\ActionStack.js:56:25)
at PluginManager.doOperation (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\cordova-common\src\PluginManager.js:114:20)
at PluginManager.addPlugin (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\cordova-common\src\PluginManager.js:144:17)
at C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\Api.js:247:74
at _fulfilled (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:854:54)
at self.promiseDispatch.done (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:883:30)
at Promise.promise.promiseDispatch (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:816:13)
at C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:570:49
(node:26116) UnhandledPromiseRejectionWarning: CordovaError: Uh oh!
"C:\xampp\htdocs\project x\anonymous-social\platforms\android\app\src\main\res\xml\camera_provider_paths.xml" already exists!
at copyNewFile (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\lib\pluginHandlers.js:261:45)
at install (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\lib\pluginHandlers.js:51:17)
at ActionStack.process (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\cordova-common\src\ActionStack.js:56:25)
at PluginManager.doOperation (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\cordova-common\src\PluginManager.js:114:20)
at PluginManager.addPlugin (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\cordova-common\src\PluginManager.js:144:17)
at C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\Api.js:247:74
at _fulfilled (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:854:54)
at self.promiseDispatch.done (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:883:30)
at Promise.promise.promiseDispatch (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:816:13)
at C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:570:49
(node:26116) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:26116) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

既然它似乎存在,我不妨尝试删除它:

$ cordova plugin rm cordova-plugin-camera 然后告诉我:

> cordova plugin remove cordova-plugin-camera --save
Uninstalling cordova-plugin-camera from android

Android Studio project detected

(node:18656) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'C:\xampp\htdocs\project x\anonymous-social\platforms\android\app\src\main\assets\www\cordova_plugins.js'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.writeFileSync (fs.js:1299:33)
at C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\cordova-common\src\PluginManager.js:134:16
at _fulfilled (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:854:54)
at self.promiseDispatch.done (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:883:30)
at Promise.promise.promiseDispatch (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:816:13)
at C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:877:14
at runSingle (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:137:13)
at flush (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
(node:18656) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:18656) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

此时,我认为我的 Android 平台存在问题,因此我删除了该平台:

$ cordova platform remove android --save
Removing platform android from config.xml file...
Removing android from cordova.platforms array in package.json

然后将其添加回来似乎工作正常,因为它返回:

--save flag or autosave detected
Saving android@~7.0.0 into config.xml file ...

有人知道发生了什么吗?我的 Android 平台似乎有点困惑,因为其他插件也在做同样的事情......有什么帮助吗?谢谢!

最佳答案

几周前我遇到了类似的问题。在几个月的时间里,我向这个项目添加了插件,由于每个插件都以其确切的版本号存储,所以我最终得到了一堆不兼容的插件版本。最后,我从一个空项目开始,添加了我需要的所有插件,然后将我的源代码复制到这个项目中。这不是一个好的解决方案,但对我来说它有效。

在你走这么远之前,你有没有

  • 删除node_modules文件夹
  • 删除平台文件夹
  • 编辑 config.xml 并删除平台条目
  • npm 我
  • ionic cordova 平台添加 android

“较小的困惑”可以通过这种方式纠正。

关于cordova - ionic - 添加插件失败,因为它已经存在,删除插件失败,因为它不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51345214/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com