0

I am trying to build my ionic project, but I get the following errors:

error: package android.content.res does not exist

error: package org.json does not exist

Does anyone know how to solve it? Thanks.

user9805040
  • 73
  • 1
  • 9

1 Answers1

1

It may be because some of your plugins are still using an old version of cordova/gradle plugins, or you didn’t updated cordova/gradle plugin of your app.

You may try:
  • Remove these cordova plugins and switch to their corresponding versions of the capacitor version your are using.
  • Another way, if you prefer you may upgrade/downgrade your Capacitor version to be compatible with the plugins your are using..
Everton Costa
  • 570
  • 5
  • 16
  • Following [this](https://stackoverflow.com/questions/28783968/update-cordova-plugins-in-one-command), I used `npm update`, but still the error is there. I prefer to not downgrade (if possible), since most likely in future I have to upgrade dependencies and packages. – user9805040 Feb 14 '23 at 20:11
  • Please, you need to uninstall the plugins and remove the platforms Android and iOS. Use the command `ionic info` to discover your Capacitor version. After that reinstall your plugins according to the capacitor version your are using... You don't need to downgrade your Capacitor version, but need to be compatible with the plugins. – Everton Costa Feb 14 '23 at 22:05
  • Thanks @Everton Costa for your replies, running `ionic cap build android` showed me I have 17 cordova plugins, I was able to upgrade 14 of them but the error is still there. This error is shown when I try to add another plugin to my project, so I just decided to use another plugin. – user9805040 Feb 15 '23 at 22:57
  • Nice to helps you @user9805040, so please mark as answer and upvote. Thanks! – Everton Costa Mar 01 '23 at 03:19
  • as I said the error was still there and I couldn't solve it. I just used another plugin. – user9805040 Mar 07 '23 at 13:51
  • Sure, you did what I suggested. Remove the Cordova plugin and add its corresponding version for Capacitor. – Everton Costa Mar 08 '23 at 18:16