Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
cordova构建android失败:找不到模块';C:[…]\platforms\android\cordova\lib\AndroidStudio';_Android_Cordova_Ionic Framework_Ionic4 - Fatal编程技术网

cordova构建android失败:找不到模块';C:[…]\platforms\android\cordova\lib\AndroidStudio';

cordova构建android失败:找不到模块';C:[…]\platforms\android\cordova\lib\AndroidStudio';,android,cordova,ionic-framework,ionic4,Android,Cordova,Ionic Framework,Ionic4,我正在构建一个Ionic应用程序,我想使用插件firebasex 不幸的是,在运行Ionic cordova构建/运行android时,我遇到以下错误: Cannot find module 'C:\[...]\platforms\android\cordova\lib\AndroidStudio' 我已经尝试了一切:删除并添加回平台,清理缓存,通过npm安装重新安装模块 这是我的环境: 离子型: 爱奥尼亚CLI:5.2.3 实用程序: cordova res:未安装 本机运行:0.2.8 系

我正在构建一个Ionic应用程序,我想使用插件
firebasex

不幸的是,在运行Ionic cordova构建/运行android时,我遇到以下错误:

Cannot find module 'C:\[...]\platforms\android\cordova\lib\AndroidStudio'
我已经尝试了一切:删除并添加回平台,清理缓存,通过
npm安装重新安装模块

这是我的环境:

离子型:

爱奥尼亚CLI:5.2.3

实用程序:

cordova res:未安装
本机运行:0.2.8

系统:

NodeJS:v10.15.3

净现值:6.4.1

操作系统:Windows 10


我只想构建和部署应用程序。

您可以执行以下步骤吗:

  • cordova clean android(或IOS)

  • rm-rf节点模块

  • npm安装

  • cordova build android

  • 在github上查看此源代码:


    希望这对您有所帮助

    您可以执行以下步骤:

  • cordova clean android(或IOS)

  • rm-rf节点模块

  • npm安装

  • cordova build android

  • 在github上查看此源代码:


    希望这对你有帮助

    你能试试这个吗

  • 有助于在应用程序中添加平台
  • 检查ANDROID_主页设置是否正确<代码>echo$ANDROID_HOME
  • 如果你设置正确。但它没有显示在命令提示符中,表示使用
    source~/.bash\u配置文件
    source~/.bashrc

  • 我希望这些对你有帮助

    你能试试流动的吗

  • 有助于在应用程序中添加平台
  • 检查ANDROID_主页设置是否正确<代码>echo$ANDROID_HOME
  • 如果你设置正确。但它没有显示在命令提示符中,表示使用
    source~/.bash\u配置文件
    source~/.bashrc
  • 我希望这些都能帮助您找到解决方案:

    创建文件\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);
    };
    
    找到解决方案:

    创建文件\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);
    };
    

    您是否添加了平台并正确配置了Android Home?您是否添加了平台并正确配置了Android Home?我的Android_Home已设置!我正在使用windows!我的安卓之家已经设置好了!我正在使用windows!