简体   繁体   中英

Can't add android platforms in cordova 3.5.0

here is the information shown in my commandline:

     $ cordova platforms add android
     Creating android project...
     Error: ENOENT, no such file or directory 'C:\Users\Administrator\.cordova\lib\android\cordova\3.5.0\VERSION'
        at Object.fs.openSync (fs.js:427:18)
        at Object.fs.readFileSync (fs.js:284:15)
        at c:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\platform.js:351:42
        at _fulfilled (c:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:798:54)
        at self.promiseDispatch.done (c:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:827:30)
        at Promise.promise.promiseDispatch (c:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:760:13)
        at c:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:821:14
        at flush (c:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:108:17)
        at process._tickCallback (node.js:419:13)
        at Function.Module.runMain (module.js:499:11)

First go to that path and see if the file it's looking for is indeed missing.

C:\\Users\\Administrator\\.cordova\\lib\\android\\cordova\\3.5.0\\VERSION

If it is then reinstall cordova using the following commands:

npm uninstall cordova -g
npm cache clean
npm install cordova -g

Then try again and see if you get the same error.

手动删除整个.cordova文件夹,然后运行cordova platform add android在项目文件夹中cordova platform add android后,SyntheCyphers的答案对我有用。

When u create a project in cordova 3.5.0, version file in .cordova is missing. So unable to add android platform. I have copied version file from 3.4.0 and paste it to 3.5.0 with version change as 3.5.0. and with it, my issue is solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM