cordova - Error: Failed to fetch platform android

后端 未结 15 2373
情深已故
情深已故 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:59

    it just because cannot dowload cordova-android package.Just do it like this,it is done: cnpm install cordova-android@^7.1.4 --save

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

    I faced same issue and I fixed by performing following steps.

    1. Please add C:\Windows\System32 in envrionment variable paths

    2. Ensure jdk/bin path is setup under JAVA_HOME and path

    3. Ensure SDK path is setup under ANDROID_HOME and path

    0 讨论(0)
  • 2020-11-29 10:01

    I had the same issue the way I fixed it was I did the following.

    1. run the command ionic platform add android This should fail and give the error your getting.
    2. It should have added a dependency to app.module.js. Now in here find "cordova-android" check it version at the time of this comment my version was 7.1.4.
    3. Open android studio and go to to project setting and make sure u have the download the same version SDK. For me this was 7.1 Nugget.
    4. create a new emulator with the same version and keep the emulator running.
    5. Go back too your IDE close it and restart the IDE.
    6. Run this command cordova platform rm android && cordova platform add android
    7. DONE! Doing this fixed my issue.

    The reason I found it was not fetching was because cordova was looking for Andriod SDK matching the version 7.1.4 but was not able to find it at the preset location normal "andriod/Sdk".

    0 讨论(0)
  • 2020-11-29 10:05

    Had the same issue after using nvm to switch node version. Just removing android platform and reinstalling it works for me:

    cordova platform rm android && cordova platform add android
    
    0 讨论(0)
  • 2020-11-29 10:06

    I had this same problem, however, the issue was a missing peer dependency on acorn.

    Adding acorn to the devDependencies section of my package.json did the trick.

    So my suggestion is to look for missing peer dependencies and add them to the devDependencies section of your package.json.

    0 讨论(0)
  • 2020-11-29 10:08

    There seems to be an error with android@6.2.x and later. I had the same issue and using the below step was able to build my apk.

    Do the following:

    cordova platform remove android
    

    Then add 6.1.2 specifically

    cordova platform add android@6.1.2
    

    Also found the following as an temporary workaround

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