Unable to generate APK once cordova social sharing plugin is installed

Hi guys, so I want to add a social sharing feature into my existing app. Hence, I ran

ionic cordova plugin add cordova-plugin-x-socialsharing
npm install @ionic-native/social-sharing

and I run my code. Code has NO ERRORS and is able to be compiled (after running ionic build & npx cap sync).

As usual, I open the android studio, everything is smooth. Then, when I press generate APK to test my app, this problem surfaces.

3 erros

  1. package android support v4 content does not exist
  2. & 3) cannot find symbol method getUriForFile (content, string, file)

Does anyone have any idea? Appreciate any help I can get.

Chances are you need to add the android support library plugin.

Another option is to use use Capacitor instead, which handles the support library automatically, as well as includes the share plugin already

May I know how to use capacitor social sharing? I presume I am using capacitor already because I always run npx cap sync then ionic capacitor open android then upload to playstore.

If you’re already using Capacitor, then why did you run ?

ionic cordova plugin add cordova-plugin-x-socialsharing

This is incorrect.

The docs on the share API can be found on the capacitor site.
https://capacitorjs.com/docs/apis/share

Before i run that, I have another backup exact project. I ran

npm install cordova-plugin-x-socialsharing
npm install @ionic-native/social-sharing
ionic cap sync

but it arises the same issues so I tried running cordova.

Sorry, freaking newbie at this, so what command should I run to use the share API?

You had it right with

npm install cordova-plugin-x-socialsharing
npm install @ionic-native/social-sharing
ionic cap sync

We cover this in the docs.
https://capacitorjs.com/docs/cordova/using-cordova-plugins

Please give the docs a read before continuing if you are not sure on things first.

Alright, will have a try.

Thank you so much!