8

I have finished a project, and I would like to build an apk. I have tried to build it, but after writing the sentences to build it, the third code gave me an error. Here the code or sentences I wrote to be built it.

ionic cordova platform remove android
ionic cordova plarform add android@6.4.0
ionic cordova build android

I have built a project 3 day ago following the code I wrode above. Here the error. ( this time I connect with firebase)

Platform android already added.
[ERROR] An error occurred while running subprocess cordova.

        cordova platform add android@6.4.0 --save exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.

E:\ionic\notasFirebase>ionic cordova build android
> ionic-app-scripts build --target cordova --platform android
[19:08:57]  ionic-app-scripts 3.2.0
[19:08:57]  build dev started ...
[19:08:57]  clean started ...
[19:08:57]  clean finished in 13 ms
[19:08:57]  copy started ...
[19:08:57]  deeplinks started ...
[19:08:57]  deeplinks finished in 61 ms
[19:08:57]  transpile started ...
[19:09:03]  transpile finished in 6.09 s
[19:09:03]  preprocess started ...
[19:09:03]  preprocess finished in 1 ms
[19:09:03]  webpack started ...
[19:09:03]  copy finished in 6.41 s
[19:09:11]  webpack finished in 8.34 s
[19:09:11]  sass started ...
[19:09:13]  sass finished in 1.66 s
[19:09:13]  postprocess started ...
[19:09:13]  postprocess finished in 29 ms
[19:09:13]  lint started ...
[19:09:13]  build dev finished in 16.44 s
[19:09:19]  lint finished in 6.02 s
> cordova build android
Unable to load PlatformApi from platform. Error: Cannot find module 'E:\ionic\notasFirebase\platforms\android\cordova\Api.js'
Unhandled error. (The platform "android" does not appear to be a valid cordova platform. It is missing API.js. android not supported.)
ionicApp
  • 81
  • 1
  • 1
  • 5
  • Try without connecting firebase and with `ionic cordova plarform add android` instead `ionic cordova plarform add android@6.4.0` – Sudarshana Dayananda Oct 15 '18 at 03:36
  • you can find last 2 line is your main error solve that and your will get your project working. Check this link https://stackoverflow.com/questions/44042641/cordova-error-your-ios-platform-does-not-have-api-js will help you to solve your issue. – CodeChanger Oct 15 '18 at 10:54
  • I follow the step steps from stakoverflow.... but the error persists. I have uploaded the node also. node -v 8.12.0 v8.12.0 – ionicApp Oct 15 '18 at 14:37

6 Answers6

12

Please try this command it work in my project.

npm i cordova-res
0

I used this method for Windows 10, the problem was fixed

enter image description here

sdkmanager.bat --licenses

I installed it

Fahimeh Ahmadi
  • 813
  • 8
  • 13
0

ERROR An error occurred while running subprocess cordova this can occur due to many reasons Plz check weather all plugins in package.json file are loading correct If any of that is deprecated or any extra plugin is present which is not useful but its in package.json remove that and build the apk this may solve the problem

  • If you have a new question, please ask it by clicking the [Ask Question](https://stackoverflow.com/questions/ask) button. Include a link to this question if it helps provide context. – Flair Aug 30 '21 at 21:36
0

If this is happening after connecting to firebase after Open the platform/android in android studio and in top menu under refactory->select Migrate to androidX

0

removing android platform and re-adding worked for me

sai kiran
  • 389
  • 2
  • 10
-3

I encountered this error, and I reinstalled Cordova:

npm uninstall -g cordova
npm install -g cordova

And it works on my side. There are other reasons for this error, so I am not sure this will work on your side.

veben
  • 19,637
  • 14
  • 60
  • 80
jackMing
  • 33
  • 2