apache/cordova-android · error · CordovaError

Please install the Android SDK Platform "platforms;${desired

Error message

Please install the Android SDK Platform "platforms;${desired_api_level}"

What it means

check_android_target compares the project's compile target string (module.exports.get_target - read from platforms/android/project.properties 'target=', e.g. android-34) against the list returned by android_sdk.list_targets(). Thrown when the exact target string is not among installed SDK platforms; the message names the missing platform package.

Source

Thrown at lib/check_reqs.js:264

                process.env.PATH += path.delimiter + cmdLineToolsBin;
            }
        }
        return hasAndroidHome;
    });
};

module.exports.check_android_target = function (projectRoot) {
    // valid_target can look like:
    //   android-19
    //   android-L
    //   Google Inc.:Google APIs:20
    //   Google Inc.:Glass Development Kit Preview:20
    const desired_api_level = module.exports.get_target(projectRoot);
    return android_sdk.list_targets().then(function (targets) {
        if (targets.indexOf(desired_api_level) >= 0) {
            return targets;
        }
        throw new CordovaError(`Please install the Android SDK Platform "platforms;${desired_api_level}"`);
    });
};

// Returns a promise.
module.exports.run = function () {
    console.log('Checking Java JDK and Android SDK versions');
    console.log('ANDROID_HOME=' + process.env.ANDROID_HOME + ' (recommended setting)');
    console.log('ANDROID_SDK_ROOT=' + process.env.ANDROID_SDK_ROOT + ' (DEPRECATED)');

    return Promise.all([this.check_java(), this.check_android()]).then(function (values) {
        console.log('Using Android SDK: ' + (process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT));

        if (!values[1]) {
            throw new CordovaError('Requirements check failed for Android SDK! Android SDK was not detected.');
        }
    });
};

View on GitHub (pinned to 7c1e190064)

Solutions

  1. Install the exact platform from the message: `sdkmanager "platforms;android-34"` (or tick it in Android Studio SDK Manager).
  2. Accept licenses if prompted: `sdkmanager --licenses`.
  3. If the platform is intentionally unavailable (old build), lower the target in project.properties/config.xml to an installed one.

Example fix

# before
$ cordova requirements android
Please install the Android SDK Platform "platforms;android-34"

# after
$ sdkmanager "platforms;android-34"
$ cordova requirements android
Defensive patterns

Strategy: validation

Validate before calling

const target = getTarget(); // value of target= in platforms/android/project.properties, e.g. android-34
const installed = (await android_sdk.list_targets());
if (!installed.includes(target)) {
  throw new Error(`Run: sdkmanager "platforms;${target}"`);
}

Type guard

const isInstalledTarget = (targets, target) => Array.isArray(targets) && targets.indexOf(target) >= 0;

Try / catch

try {
  await check_reqs.check_android_target(projectRoot);
} catch (e) {
  if (/Please install the Android SDK Platform/.test(e.message)) {
    const platform = /"platforms;([^"]+)"/.exec(e.message)[1];
    await execa('sdkmanager', [`platforms;${platform}`]); // auto-provision, then retry
    return check_reqs.check_android_target(projectRoot);
  }
  throw e;
}

Prevention

When it happens

Trigger: `cordova requirements android`, or a build that runs the target check, when the project targets android-34 but the SDK only has older platforms installed - typical after raising android-targetSdkVersion/config.xml target or cloning the project onto a fresh machine/CI image.

Common situations: New developer machine or CI image missing that platform; a plugin raising the required target; project.properties regenerated with a newer default target after a platform update.

Related errors


AI-assisted analysis of apache/cordova-android@7c1e190064 (2026-08-22). Data as JSON: /api/errors/a73901c51b357f3d. Report an issue: GitHub.