hardeep
hardeep

Reputation: 1

Could not add android platform to cordova project from cordova CLI

I am having problems in adding android platform to my cordova project. All things that are required have been installed. I have jdk,sdk for android, npm, git and cordova. All have latest version as of 06/14/2017. I am able to create cordova project with the command cordova create myapp.

But after the app is successfully created and when I run cordova platform add android from within the myapp folder I get an error. I have tried everything but could not get it done. I have already set ANDROID_HOME, added Android SDK tools and platform-tools directories to PATH, used --nofetch but to no avail.

Below is the command prompt error message after I run my command cordova platform add android

Using cordova-fetch for cordova-android@~6.2.2 

Error: Failed to fetch platform cordova-android@~6.2.2 

Probably this is either a connection problem, or platform spec is incorrect. Check your connection and platform name/version/URL. 

Error: cmd: Command failed with exit code 1

Error output: npm ERR! shasum check failed for
C:\Users\PARAS~1.SHA\AppData\Local\Temp\npm-3048-83f48a6f\registry.npmjs.org\cordova-android\-\cordova-android-6.2.3.tgz

npm ERR! Expected: 249f21b6ce5f1f1c847a7ab83b16909dbed5aa28 

npm ERR! Actual: ace33a120d0172a175c73e708f0552cc205731b0 

npm ERR! From: http://registry.npmjs.org/cordova-android/-/cordova-android-6.2.3.tgz

npm ERR! A complete log of this run can be found in: 

npm ERR! C:\Users\paras.sharma\AppData\Roaming\npm-cache\_logs\2017-06-14T11_09_17_075Z-debug.log

Upvotes: 0

Views: 518

Answers (1)

pro_cheats
pro_cheats

Reputation: 1582

Error: Failed to fetch platform cordova-android@~6.2.2
npm ERR! Expected: 249f21b6ce5f1f1c847a7ab83b16909dbed5aa28  
npm ERR! Actual: ace33a120d0172a175c73e708f0552cc205731b0 
From: http://registry.npmjs.org/cordova-android/-/cordova-android-6.2.3.tgz

I have experienced the above error before.

This error occurs when the downloaded cordova-android-6.2.3.tgz is incomplete or currupt. Or npm is looking for a lower version 6.2.2.

npm is expecting the hash digest (MD5 or SHA1) 249f21b6ce5f1f1c847a7ab83b16909dbed5aa28 for the downloaded file while adding the android platform. But your downloaded file has ace33a120d0172a175c73e708f0552cc205731b0.

Quick Fix -

  • DELETE the downloaded file cordova-android-6.2.3.tgz or folder npm-304 8-83f48a6f in -

    C:\Users\PARAS~1.SHA\AppData\Local\Temp\npm-304 8-83f48a6f\registry.npmjs.org\cordova-android-\cordova-android-6.2.3.tgz 
    
  • And do cordova platform add android again. npm will redownload the required file.

You can also download it manually (7.7 MB) from here and place it in the same folder and then run the command.

Upvotes: 3

Related Questions