cordova - Error: Failed to fetch platform android

后端 未结 15 2371
情深已故
情深已故 2020-11-29 09:19

I installed cordova and create a new project.

But when I use this command to add android platform:

cordova platform add android

相关标签:
15条回答
  • 2020-11-29 09:48

    I faced the same problem today, none of the answers mentioned above works for me. It turns out to be a permission problem, just simply add a sudo ahead.

    sudo cordova platforms add android
    

    I am using Mac OS by the way

    0 讨论(0)
  • 2020-11-29 09:54

    In my case(MacOS),

    1. Run the command cordova platform rm android

    2. Check package.json successfully deleted cordova-android.

    3. Run the command sudo cordova platform rm android

    4. It worked.:)

    0 讨论(0)
  • 2020-11-29 09:55

    Add C:\Windows\System32 at the end of your path in environment variables if not exist before. Then close cmd and open it again and run:

    cordova platfom add android

    0 讨论(0)
  • 2020-11-29 09:57

    you can check the android version provided by cordova by typing cordova platform ls inside projectname/cordova folder. I refered from below url https://cordova.apache.org/docs/en/latest/guide/platforms/android/.
    (For me .cordova/lib folder was empty).

    Then add that platform from inside project's cordova folder by executing cordova platform add android@5.1.1 (in my case, solved the issue).

    0 讨论(0)
  • 2020-11-29 09:57

    When I tried to remove the android platform from my project directory using this command: cordova platform rm android, it failed.But I managed to do it using the following steps:

    1. I deleted cordova-android folder manually from node_modules.
    2. Removed cordova-android dependency from package.json.
    3. Executed this command from terminal : cordova platform add android --nofetch.

    After these the Platform was added successfully.

    0 讨论(0)
  • 2020-11-29 09:59

    Did you copy or clone your project from somewhere else? Normally these errors have to do with incompatibilities between your cordova version and your platform configuration files.

    update your cordova to the latest version

    npm -g update cordova
    

    Then remove and add the platform again

    cordova platform rm android && cordova platform add android
    
    0 讨论(0)
提交回复
热议问题