离子移动开发;在 Ionic 中准备 android 时出错

Ionic mobile development; Error when preparing android in Ionic

我在添加 android 平台并准备 android 时遇到错误。

当我运行以下命令时:-

 ionic capacitor add android

我收到以下错误:-

[error] "android" platform already exists. To add a new "android" platform, please remove "D:\ionic\myapp\android" and run this command again. WARNING! your native IDE project will be completely removed. [ERROR] An error occurred while running subprocess capacitor. capacitor.cmd add android exited with exit code 1.

我使用以下命令更新了 android:-

ionic capacitor update android

它更新了我的 android : -

capacitor.cmd update android √ Updating Android plugins in 73.77ms
Found 0 Capacitor plugins for android: √ update android in 473.61ms Update finished in 0.593s

然后我尝试准备 android 在 Android 工作室开始 :-

ionic cordova prepare android

我收到以下错误:-

cordova.cmd platform add android --save Error: npm: Command failed with exit code 1 Error output: npm ERR! code ENOLOCAL npm ERR! Could not install from "android" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\USER\AppData\Roaming\npm-cache_logs20-08-14T09_02_55_668Z-debug.log at ChildProcess.whenDone (C:\Users\USER\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\superspawn.js:135:23) at ChildProcess.emit (events.js:223:5) at ChildProcess.cp.emit (C:\Users\USER\AppData\Roaming\npm\node_modules\cordova\node_modules\cross-spawn\lib\enoent.js:34:29) at maybeClose (internal/child_process.js:1021:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) { stderr: 'npm ERR! code ENOLOCAL\n' + 'npm ERR! Could not install from "android" as it does not contain a package.json file.\n' + '\n' + 'npm ERR! A complete log of this run can be found in:\n' + 'npm ERR! C:\Users\USER\AppData\Roaming\npm-cache\_logs20-08-14T09_02_55_668Z-debug.log\n', code: 1 } [ERROR] An error occurred while running subprocess cordova. cordova.cmd platform add android --save exited with exit code 1. Re-running this command with the --verbose flag may provide more information.

我尝试删除 cordova 并重新安装。但它不起作用。

我有没有漏掉什么插件。我在项目的开头添加了电容器。

任何人都可以提出任何解决方案吗?

要在 Android Studio 上启动 ionic 应用程序,请执行以下命令。

ionic capacitor run android