android - cordova build android 失败:找不到模块'C:[...]\platforms\android\cordova\lib\AndroidStudio'
问题描述
我正在构建一个 Ionic 应用程序,我想使用该插件firebasex
。
不幸的是,在运行 Ionic cordova build/run android 时,我收到以下错误:
Cannot find module 'C:\[...]\platforms\android\cordova\lib\AndroidStudio'
npm install
我已经尝试了一切:删除并重新添加平台,清理缓存,通过...重新安装模块
这是我的环境:
离子:
离子 CLI:5.2.3
效用:
cordova-res:未安装
本机运行:0.2.8
系统:
节点JS:v10.15.3
npm:6.4.1
操作系统:Windows 10
我只想构建和部署应用程序。
解决方案
找到了解决方案:
创建文件 \platforms\android\cordova\lib\AndroidStudio.js
/*
* This is a simple routine that checks if project is an Android Studio Project
*
* @param {String} root Root folder of the project
*/
/* jshint esnext: false */
var path = require('path');
var fs = require('fs');
var CordovaError = require('cordova-common').CordovaError;
module.exports.isAndroidStudioProject = function isAndroidStudioProject (root) {
var eclipseFiles = ['AndroidManifest.xml', 'libs', 'res'];
var androidStudioFiles = ['app', 'app/src/main'];
// assume it is an AS project and not an Eclipse project
var isEclipse = false;
var isAS = true;
if (!fs.existsSync(root)) {
throw new CordovaError('AndroidStudio.js:inAndroidStudioProject root does not exist: ' + root);
}
// if any of the following exists, then we are not an ASProj
eclipseFiles.forEach(function (file) {
if (fs.existsSync(path.join(root, file))) {
isEclipse = true;
}
});
// if it is NOT an eclipse project, check that all required files exist
if (!isEclipse) {
androidStudioFiles.forEach(function (file) {
if (!fs.existsSync(path.join(root, file))) {
console.log('missing file :: ' + file);
isAS = false;
}
});
}
return (!isEclipse && isAS);
};
推荐阅读
- java - 如何获得所有加起来形成一个数字的连续数字集?
- reactjs - 在 TextField 组件内添加元素 - 材质 UI
- angular - 使用带有比较运算符的 ng-if
- kotlin - += 和添加到 Kotlin 中的 MutableList 之间的区别
- java - JOOQ:根据长度将 tinyint 映射到布尔值
- curl - 禁止卷曲消息:如何格式化 curl 命令?
- java - ExoPlayer:将控制器放置在视频下方而不与视频重叠
- python - Google Photos API - 列表库内容 - “请求包含无效参数” - 最近更改?
- nginx - Nginx pagespeed 模块在没有过滤器的情况下增加页面大小?
- android - 如果孩子是空的,则隐藏将孩子分组的约束布局