ionic unable to add SocialSharing-PhoneGap-Plugin - android

I am trying to use SocialSharing-PhoneGap-Plugin in my first app development,
https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin#web-share-api
I have tried following command :
cordova plugin add SocialSharing-PhoneGap-Plugin
cordova plugin add https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git
but It gives me same error , Anyone know what the problem is?

Some plugins can install in specific versions of cordova.
so please downgrade your cordova version and try to install that plugin again.
if your cordova version is 7+, downgrade to 6.5.0
npm install -g cordova#6.5.0

The plugin name is case sensitive, so the right one is:
cordova plugin rm cordova-plugin-x-socialsharing

Related

Unable to add android project - ionic( Error - com.couchbase.lite.phonegap)

I am trying to add android platform to my existing ionic project. I am getting the below error.
Failed to restore plugin com.couchbase.lite.phonegap from config.xml. You might need to try adding it again.
Error:
Error: npm: Command failed with exit code 1 Error output:
I guess you tried on Android >= 7 which is needed for the couchbaselite plugin.
so you can downgrade to 6 :
ionic cordova platform rm android
ionic cordova platform add android#6
But if you need a recent android, you have to apply this Fixes : https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin/pull/110
remove manually node-modules and package-lock.json (imp*)
npm cache clean --force
finally run npm install
ionic cordova platform add android
I suggest you to remove the plugin and it's folder:
ionic cordova plugin remove couchbase-lite-phonegap-plugin
rm -rf plugins/com.couchbase.lite.phonegap/
Also, remove any line in package.json using the wrong folder name of com.couchbase.lite.phonegap, if you find any.
Then add your android platform as usual, then add the plugin back.
ionic cordova platform add android
ionic cordova plugin add couchbase-lite-phonegap-plugin
And if you still get any error, repeat the operation using the cordova --verbose directly, without ionic command. Example:
cordova plugin add couchbase-lite-phonegap-plugin --verbose
That command above should tell you exactly what went wrong.

cordova-plugin-facebook4 Couldn't Make The App Start (Android)

I have an existing app which this plugin runs fine, but today it decides to fail on me.
I can be certain that the below will very likely to re-produce the issue, once the plugin was installed, the app resulted to a blank screen after running "cordova run android". Terminal showed "LAUNCHED SUCCESS", no errors/stack trace.
Versions:
cordova-plugin-facebook4: 2.4.0
cordova: 8.0.0
cordova-android: 7.0.0
Android Studio: 3.1.4 (for Mac) with Android API 28
To reproduce this:
Fresh install of Android Studio and cordova, accept all licenses from Android e.g. sdkmanager --licenses. Make sure that app is registered in developers.facebook.com with get a proper APP_ID.
Terminal: cordova create appy222 appy222.com appy222
cd into the appy222
cordova plugin add cordova-plugin-facebook4 --variable APP_ID="whateverid" --variable APP_NAME="Appy222"
Insert the xml fragment to cordova-plugin-facebook4's plugin.xml <config-file parent="/resources" target="./res/values/strings.xml">
<string name="fb_app_id">$APP_ID</string>
<string name="fb_app_name">$APP_NAME</string>
</config-file>
Change the "android-minSdkVersion" to 16. The original was 15, it complained Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be smaller than version 16 declared in library... when doing cordova run android
cordova platform add android this will install cordova-android#7.0.0
Run by hooking up to the Android mobile phone with develop options enabled. Terminal: cordova run android
And the result was a blank screen...black. The app will run fine without cordova-plugin-facebook4.
Wonder if anybody came across this problem? Hope that someone could share some thoughts here.
Had the same problem. What worked for me was removing the plugin, setting the facebook android sdk version to 4.35.0:
cordova plugin add cordova-plugin-facebook4 --variable APP_ID="whateverid" --variable APP_NAME="Appy222" --variable ANDROID_SDK_VERSION="4.35.0"
Then removing and readding the android platform:
cordova platform rm android
cordova platform add android
Android build.gradle couldn't found $FACEBOOK_ANDROID_SDK_VERSION.
So I changed it in ionic-cordova-facebook4 plugin.
You can find root/plugins/cordova-plugin-facebook4/plugin.xml file.
Here you can find this setting
please change it to
finally
ionic cordova platform rm android,
ionic cordova platform add android
ionic cordova run android
Now All is ok!
Posting an answer to my own question/problem. Seems that I need to down the Facebook's Android SDK version all the way to just 4.28.0 (instead of 4.36.0 which is the current at the moment of writing).
cordova plugin add cordova-plugin-facebook4 --variable APP_ID="whateverid" --variable APP_NAME="whateverappname" --variable ANDROID_SDK_VERSION="4.28.0"
You need to downgrade Facebook Android SDK version to 4.26.0
ionic cordova plugin add cordova-plugin-facebook4 --variable APP_ID="app_id" --variable APP_NAME="app_name" --variable FACEBOOK_ANDROID_SDK_VERSION="4.26.0" --variable ANDROID_SDK_VERSION="4.26.0"
Remember to set both the variables ANDROID_SDK_VERSION & FACEBOOK_ANDROID_SDK_VERSION to avoid conflicts as some of the versions of cordova-plugin-facebook4 was referring to variable ANDROID_SDK_VERSION
Remember to remove and add android platform again.
Me too. I got the solution.It must be same name Google Play Package Name in dev facebook app and wiget id in config.xml.

Ionic + Angular - Platform Add Android Error - Error: Failed to fetch platform cordova-android#0.0.8

Okay, so you run this. And it continues to fail.
cordova platform add android --save
And the output is this.
Error: Failed to fetch platform cordova-android#0.0.8
After trying to reinstall cordova, node, and other packages, I have had no luck. I am running this with the ionic blank starter package with ionic Cli 3.
For some reason with the latest version of everything, ionic, angular, the cli, etc, the platform was trying to add
cordova-android#0.0.8
To fix this, just go to this link and get the latest version, and run this...
sudo ionic cordova platform add android#6.4.0
I had the same issue and followed this link
https://github.com/apache/cordova-android/releases
There, I found that the latest version is 7.1.1
I tried this ionic cordova platform add android#7.1.1 but got the same error
From a forum I follow, I got this link https://www.npmjs.com/package/cordova-android
Then I tried this ionic cordova platform add android#7.1.0 and it ran as I expected
remove old android
ionic cordova platform rm android
add latest android
ionic cordova platform add android#latest

Install Cordova plugin without package.json file on it

I'm trying to install a Cordova Plugin with Cordova CLI 7.
This plugin does not have a package.json file on it, so it throws an error when adding it to my project.
I've tried converting the config.xml file using plugman. And it works fine for Android but it doesn't for iOS. I feel like I'm missing some configuration from the config.xml in my package.json file.
Is there a way to safely convert the config.xml in a package.json file? or a way to install it using the config.xml file?
Thanks
Yes, since Cordova 7, the installation of platforms and plugins are by default performed using cordova-fetch which in turn uses npm install to add/remove modules. Therefore a package.json is required by default. But you should be able to add plugins lacking a package.json file by using the nofetch parameter, which forces Cordova to use the old method instead, please note that this parameter has been removed in cordova 8.0.0:
cordova plugin add cordova-plugin-camera --nofetch
For me when adding a custom plugin like so
cordova plugin add .\custom-plugins\my-plugin --nofetch
This does not work on MAC for me for some reason.
I resort to building it all for Android then copy over all the files, except node_modules and platforms, then do a 'cordova build ios' it seems to build fine with the custom plugins included. Not the best way i know, but once the plugin is added i can move on and continue. If you get it to work please share.
--nofetch option is removed in Cordova 8.0.0: https://issues.apache.org/jira/browse/CB-13055
If you have already installed Cordova 8.x.x then you can downgrade it to version 7.1.0 and then use the --nofetch option.
Run the following command to downgrade Cordova to 7.1.0:
npm install -g cordova#7.1.0
If the above command doesn't work, then try uninstalling cordova at first and then install cordova version 7.1.0:
npm uninstall -g cordova
npm install -g cordova#7.1.0
Then, check the Cordova version:
cordova --version

cordova plugin rm cordova-plugin-whitelist does not change config.xml so it will be readded upon build

When I run
cordova plugin rm cordova-plugin-whitelist
and then run
cordova build android
I get the following message:
Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
Fetching plugin "cordova-plugin-whitelist#1" via npm
Installing "cordova-plugin-whitelist" for android
This plugin is only applicable for versions of cordova-android greater
than 4.0. If you have a previous platform version, you do not need
this plugin since the whitelist will be built in.
and then the build proceeds.
So cordova plugin rm is not removing the plugin as I never installed it, as it should?
edit
Removing this plugin will make the webview blank. I expected it to accept any url, but it rejected everything.
I'm not sure what your question is here. In order to remove the plugin from the config.xml file, you'll need to add the --save flag to the cordova plugin rm call (reference):
cordova plugin rm <plugin-id> --save
Without the --save flag, the plugin is removed from the app, but not from the config.xml file.
So when you next call cordova build or cordova prepare, the script will look at your config.xml file and add any plugins that are specified there but not installed. So the plugin will be added back.

Categories

Resources