I have an angular 13 app and an Ionic 6 app in a monorepo
After migrate from capacitor 3.5.1 to 4.0.1, I got this message when trying to run the application on Android Studio 2021.2.1 Patch 1
…\getcapacitor\AndroidProtocolHandler.java:7: error: package android.content does not exist import android.content.Context;
this is a screenshot capacitor and ionic entries on monorepo’s package.json
The process I follow to test the app is this:
- remove node_modules & package-lock.json
- npm i
- npx build ionic-app
- npx jetify
- npx cap sync android
- npx cap open android
I have already tried this:
deleting android project and adding it again,
manual migration modifying package.lock
migration using ionic plugin “Ionic v1.9.4” through recomendations section
How can I fix it?
that happens when some of your plugins are still using an old version of gradle/gradle plugin, or you didn’t update gradle/gradle plugin in your app.
How did you migrate to capacitor 4? manually? vs extension? migrate command?
what’s your capacitor plugins list?
I’m running into this exact same issue. The errors are happening in the capacitor-android module itself. I upgraded “manually”, by updating all
For me, the issue was that I overlooked the
@capacitor/cli dependency. After I updated that dependency to
~4.2.0, and then deleted the
/android folder (
rm -rf android), and re-added it (
npx cap add android) it works!
Current capacitor dependencies for my project:
We had the same problem. Upgraded to cap 4 via the migration tool and everything went smoothly for ios. on android that’s where it started to blow up.
We are still using cordova plugins and the majority of them need to be updated to support the new stuff. Checked a few repos of the problematic plugins and they are all out of date (3+ years old). Some have fixes from members but the plugin developers themselves have not merged those fixes or don’t intend to.
So we have 2 options:
Remove those cordova plugins and switch over to the capacitor version which would take some time.
Hold off on upgrading to cap 4 until 2 weeks before mandatory update.
We decided to go with option 2. There is still 2 whole months to give the plugin owners time to update.