Ionic plugin need to remove platform and read platform before it works

31,577

Solution 1

You can add all your plugins using the option --save:

cordova plugin add com.ionic.keyboard --save
cordova plugin add org.apache.cordova.camera --save

etc etc.

Or you can do it after all your plugins have been added:

cordova plugin save

You can do the same thing for your platform:

cordova platform add android --save

or later:

cordova platform save

these commands will add some new sections to your config.xml file:

<plugin name="org.apache.cordova.device" spec="^0.3.0" />
...

and

<engine name="android" spec="^4.0.0" />

now you can delete platforms and plugins folder and run:

cordova prepare

and it should create the platform and download all the plugins for you.

You can find some more info here.

Solution 2

Following steps helped me

ionic platform rm android
ionic platform add android
ionic plugin add https://github.com/apache/cordova-plugin-whitelist.git
ionic build android

Then you can deploy your apk

Solution 3

Following steps Step 1:C:\Users\vipin>cd C:\Users\vipin\Documents\GitHub\Applozic-Server\Applozic-Ionic-Chat-Plugin

//change directory ,where your app is Located

Step 2: ionic platform add android // or ios ex:C:\Users\vipin\Documents\GitHub\Applozic-Server\Applozic-Ionic-Chat-Plugin>ionic platform add android

Step 3: ionic build android ex :C:\Users\vipin\Documents\GitHub\Applozic-Server\Applozic-Ionic-Chat-Plugin> ionic build android

Step 4: if you want to remove your platform . follow this step C:\Users\vipin\Documents\GitHub\Applozic-Server\Applozic-Ionic-Chat-Plugin>ionic platform rm android

Note : again you want to add platform . please go through step 1 to step 3

Share:
31,577
Harts
Author by

Harts

Updated on October 21, 2020

Comments

  • Harts
    Harts over 3 years

    I have package.json like this,

      "cordovaPlugins": [
        "com.ionic.keyboard",
        "org.apache.cordova.camera",
        "org.apache.cordova.console",
        "org.apache.cordova.device",
        "org.apache.cordova.dialogs",
        "org.apache.cordova.file",
        "org.apache.cordova.file-transfer",
        "org.apache.cordova.geolocation",
        "org.apache.cordova.network-information",
        "org.apache.cordova.splashscreen",
        "cordova-plugin-whitelist",
      ],
      "cordovaPlatforms": [
        "ios",
        "android"
      ]
    

    The root project directory does not have plugins and platforms directory, when I pull from repository. so I run "ionic platform add android", which will create the platforms directory and install the plugin.

    But it does not work, until I run "ionic platform rm android" then "ionic platform add android" again, suddenly it works fine.

    What cause this? and how to solve this, so next developer can pull the repo and directly make it work just by running "ionic platform add android" once?

    I'm using latest cordova