无法将Android平台添加到离子项目

时间:2020-01-28 17:51:56

标签: android angular cordova-plugins ionic4

我尝试构建APK,但出现此错误

Discovered saved plugin "im.ltdev.cordova.UserAgent". Adding it to the project
Failed to restore plugin "im.ltdev.cordova.UserAgent" from config.xml. You might need to try adding it again. Error: Error: npm: Command failed with exit code 1 Error output:
npm ERR! code E404
npm ERR! 404 Not found : im.ltdev.cordova.UserAgent
npm ERR! 404
npm ERR! 404  'im.ltdev.cordova.UserAgent' is not in the npm registry.
npm ERR! 404 Your package name is not valid, because
npm ERR! 404  1. name can no longer contain capital letters
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Desarrollo\AppData\Roaming\npm-cache\_logs\2020-01-28T17_27_27_131Z-debug.log
Discovered saved plugin "cordova-plugin-firebase". Adding it to the project
Failed to restore plugin "cordova-plugin-firebase" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin git+https://github.com/dpa99c/cordova-plugin-firebase.git#GH-1057-April-05-android-build-issue via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR! code ENOGIT
npm ERR! Error while executing:
npm ERR! undefined ls-remote -h -t https://github.com/dpa99c/cordova-plugin-firebase.git
npm ERR!
npm ERR! undefined
npm ERR! No git binary found in $PATH
npm ERR!
npm ERR! Failed using git.
npm ERR! Please check if you have git installed and in your PATH.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Desarrollo\AppData\Roaming\npm-cache\_logs\2020-01-28T17_27_31_601Z-debug.log
cordova-android-support-gradle-release: Android platform: V7+
cordova-android-support-gradle-release: Wrote custom version '27.+' to C:\Users\Desarrollo\Desktop\lugus-3-0\platforms\android\app\build.gradle
cordova-android-support-gradle-release: Wrote custom version '27.+' to C:\Users\Desarrollo\Desktop\lugus-3-0\platforms\android\cordova-android-support-gradle-release\SanDiego-cordova-android-support-gradle-release.gradle
cordova-plugin-androidx: Updated gradle.properties to enable AndroidX
cordova-plugin-androidx-adapter: Processed 18 Java source files in 450ms
[ERROR] An error occurred while running subprocess cordova.

        cordova.cmd platform add android exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.

这是我的离子信息

离子:

离子CLI:5.4.15(C:\ Users \ Desarrollo \ AppData \ Roaming \ npm \ node_modules \ ionic 离子框架:@ ionic / angular 4.0.0-beta.17 @ angular-devkit / build-angular:0.803.23 @ angular-devkit / schematics:7.0.7 @ angular / cli:7.0.7 @ ionic / angular-toolkit:1.2.0

科尔多瓦: Cordova CLI:未安装 Cordova平台:Android 8.1.0 Cordova插件:cordova-plugin-ionic-keyboard 2.2.0,cordova-plugin-ionic-webview 2.5.2(和其他10个插件)

实用程序: 科尔多瓦水库:0.9.0 本机运行:未安装

系统: NodeJS:v11.1.0(C:\ Program Files \ nodejs \ node.exe) npm:6.4.1 操作系统:Windows 10

1 个答案:

答案 0 :(得分:0)

似乎package.json中的节点模块名称错误。

请更新您的package.json以使用cordova-plugin-agent,清理node_modules目录和NPM缓存,然后重新安装。

希望有帮助。

还请参考具有相同信息的问题here on github