简体   繁体   中英

Error 'Unable to load PlatformApi from the platform' when trying to install Cordova Android Platform 9 and target Android API 29

I have and app that run fine with Cordova 8.1.1 and Cordova Android Platform 8.1.2. Now, Google requires that all apps must be summitted using at least Android API 29. I already setup in the config.xml the following elements:

<platorm name="android">
        <preference name="android-minSdkVersion" value="22" />
        <preference name="android-targetSdkVersion" value="29" />
</platorm>

But cordova android 8.1.2 seems to ignore this requirement in the build steps.

After reading the Cordova Blog Website I noticed that there's a new version for the Android platform. The new version 9.0.0 targets by default to API 29.

I'm tried to install Cordova Android platform version 9:

cordova platform add android@9.0.0

but I get an error while doing it:

Unable to load PlatformApi from the platform. SyntaxError: Unexpected token {
Unhandled "error" event. (The platform "android" does not appear to be a valid Cordova platform. It is missing API.js. android not supported.)

I'm currently using Cordova 8.1.2 and I need to update to Android platform version 9 so my app can be compiled with Android API 29 (requested by Google Play).

  • Node version: v8.17.0
  • Cordova version: 8.1.1
  • Cordova Android: 9.0.0

What I'm missing so I can add the Android platform and compile to API 29?

I finally solved the same problem by upgrading Node from version 8 to version 11.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM