Skip to content

Missing or incomplete platform or plugin folders are ignored by Cordova and result in incomplete builds #1731

@fudom

Description

@fudom

Bug Report

Problem

When I run a cordova build on a fresh git cloned project, after npm install, the following error occurs:

Failed to install 'cordova-plugin-statusbar': 
  Error: C:\path-to-app\platforms\android\cdv-gradle-config.json: ENOENT: no such file or directory, 
  open 'C:\path-to-app\platforms\android\cdv-gradle-config.json'

My workaround, is adding a pre build script which adds the platform again:

if (!existsSync('platforms/android/android.json')) {
  const cordovaAndroidVersion = devDependencies['cordova-android'];
  execSync(`cordova platform add android@${cordovaAndroidVersion}`, { stdio: 'inherit' });
}

But then, sometimes the following error appears:

CordovaError: Platform android already added.
  at C:\path-to-app\node_modules\cordova-lib\src\cordova\platform\addHelper.js:120:35

Command or Code

cordova build android --release

I think we should ensure that the platform incl. folder structure exists on npm i or cordova build. Because it's already defined in package.json.

Environment, Platform, Device

Windows 11, Node 20.14, cordova-android 13

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions