I installed cordova and create a new project.
我安装了cordova并创建了一个新项目。
But when I use this command to add android platform:
但是当我使用这个命令添加android平台时:
cordova platfom add android
cordova platfom添加android
this error appears:
出现此错误:
Error: Failed to fetch platform android
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: version not found: cordova-android@5.1.0
This is how I created the new project:
这就是我创建新项目的方式:
cordova create hello com.example.hello HelloWorld
cordova创建hello com.example.hello HelloWorld
And this is my SDK Manager:
这是我的SDK Manager:
But I can add ios platform (But I work on Windows)
但我可以添加ios平台(但我在Windows上工作)
6 个解决方案
#1
11
I had the same problem with the android@5.1.1 version. I solved this issue, checking what version of android is provided by cordova. You can check it in C:/Users/%USER%/.cordova/lib/npm-cache/cordova-android
我对android@5.1.1版本有同样的问题。我解决了这个问题,检查了cordova提供的android版本。您可以在C:/ Users /%USER%/。cordova / lib / npm-cache / cordova-android中查看它
Then, you install the android platform version provided. For me it was @5.1.0 which was in my cordova-android folder. So I used the cmd line following:
然后,您安装提供的Android平台版本。对我来说,这是我的cordova-android文件夹中的@ 5.1.0。所以我使用了以下cmd行:
cordova platform add android@5.1.0 which should be a differnet version for you.
cordova平台添加android@5.1.0,这应该是一个不同的版本。
Kind regards !
亲切的问候 !
#2
6
Had the same issue after using nvm to switch node version. Just removing android platform and reinstalling it works for me:
使用nvm切换节点版本后有同样的问题。只需删除android平台并重新安装它对我有用:
cordova platform rm android && cordova platform add android
#3
3
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).
你可以通过在projectname / cordova文件夹中键入cordova platform ls来检查cordova提供的android版本。我在下面提到了网址https://cordova.apache.org/docs/en/latest/guide/platforms/android/。 (对我来说.cordova / lib文件夹是空的)。
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).
然后通过执行cordova平台添加android@5.1.1(在我的情况下,解决了问题)从项目的cordova文件夹中添加该平台。
#4
2
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.
android@6.2.x及更高版本似乎有错误。我有同样的问题,使用下面的步骤能够构建我的apk。
Do the following:
请执行下列操作:
cordova platform remove android
Then add 6.1.2 specifically
然后专门添加6.1.2
cordova platform add android@6.1.2
Also found the following as an temporary workaround
还发现以下作为临时解决方法
cordova platform add android --nofetch
#5
0
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:
如果以前不存在,请在环境变量的路径末尾添加C:\ Windows \ System32。然后关闭cmd并再次打开它并运行:
cordova platfom add android
cordova platfom添加android
#6
-1
I spent a full three days on this issue
我在这个问题上花了整整三天时间
it be solved since i found remove this dir: C:\Users\win\.cordova
它解决了,因为我发现删除这个目录:C:\ Users \ win \ .cordova
and run npm uninstall cordova -g
并运行npm uninstall cordova -g
npm i cordova -g
npm i cordova -g
then no error and warning
然后没有错误和警告
#1
11
I had the same problem with the android@5.1.1 version. I solved this issue, checking what version of android is provided by cordova. You can check it in C:/Users/%USER%/.cordova/lib/npm-cache/cordova-android
我对android@5.1.1版本有同样的问题。我解决了这个问题,检查了cordova提供的android版本。您可以在C:/ Users /%USER%/。cordova / lib / npm-cache / cordova-android中查看它
Then, you install the android platform version provided. For me it was @5.1.0 which was in my cordova-android folder. So I used the cmd line following:
然后,您安装提供的Android平台版本。对我来说,这是我的cordova-android文件夹中的@ 5.1.0。所以我使用了以下cmd行:
cordova platform add android@5.1.0 which should be a differnet version for you.
cordova平台添加android@5.1.0,这应该是一个不同的版本。
Kind regards !
亲切的问候 !
#2
6
Had the same issue after using nvm to switch node version. Just removing android platform and reinstalling it works for me:
使用nvm切换节点版本后有同样的问题。只需删除android平台并重新安装它对我有用:
cordova platform rm android && cordova platform add android
#3
3
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).
你可以通过在projectname / cordova文件夹中键入cordova platform ls来检查cordova提供的android版本。我在下面提到了网址https://cordova.apache.org/docs/en/latest/guide/platforms/android/。 (对我来说.cordova / lib文件夹是空的)。
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).
然后通过执行cordova平台添加android@5.1.1(在我的情况下,解决了问题)从项目的cordova文件夹中添加该平台。
#4
2
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.
android@6.2.x及更高版本似乎有错误。我有同样的问题,使用下面的步骤能够构建我的apk。
Do the following:
请执行下列操作:
cordova platform remove android
Then add 6.1.2 specifically
然后专门添加6.1.2
cordova platform add android@6.1.2
Also found the following as an temporary workaround
还发现以下作为临时解决方法
cordova platform add android --nofetch
#5
0
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:
如果以前不存在,请在环境变量的路径末尾添加C:\ Windows \ System32。然后关闭cmd并再次打开它并运行:
cordova platfom add android
cordova platfom添加android
#6
-1
I spent a full three days on this issue
我在这个问题上花了整整三天时间
it be solved since i found remove this dir: C:\Users\win\.cordova
它解决了,因为我发现删除这个目录:C:\ Users \ win \ .cordova
and run npm uninstall cordova -g
并运行npm uninstall cordova -g
npm i cordova -g
npm i cordova -g
then no error and warning
然后没有错误和警告