Cordova platform add android failed

Failed to fetch platform cordova-android@8.0.0 #803

Comments

Sampath-Lokuge commented Aug 8, 2019 •

Below error shows when I tried to ionic cordova platform add android@8.0.0

Note: I have tried many times.

I have done this:

rm -rf node_modules/
rm -rf platforms/
rm -rf plugins/

Removed package.lock.json and tried npm i But no luck yet. Any clue?

ionic cordova platform add android@8.0.0

cordova.cmd platform add android@8.0.0
Using cordova-fetch for cordova-android@8.0.0
Failed to fetch platform cordova-android@8.0.0
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! Windows_NT 10.0.17763
npm ERR! argv «C:\Program Files\nodejs\node.exe» «D:\Clients\ionic4\node_modules\npm\bin\npm-cli.js» «install» «cordova-android@8.0.0» «—production» «—save»
npm ERR! node v12.4.0
npm ERR! npm v2.15.12
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package @ionic-native/core@5.11.0 does not satisfy its siblings’ peerDependencies requirements!
npm ERR! peerinvalid Peer @ionic-native/android-permissions@5.11.0 wants @ionic-native/core@^5.1.0
npm ERR! peerinvalid Peer @ionic-native/document-viewer@5.11.0 wants @ionic-native/core@^5.1.0
npm ERR! peerinvalid Peer @ionic-native/file@5.11.0 wants @ionic-native/core@^5.1.0
npm ERR! peerinvalid Peer @ionic-native/file-opener@5.11.0 wants @ionic-native/core@^5.1.0
npm ERR! peerinvalid Peer @ionic-native/file-transfer@5.11.0 wants @ionic-native/core@^5.1.0
npm ERR! peerinvalid Peer @ionic-native/firebase-x@5.11.0 wants @ionic-native/core@^5.1.0
npm ERR! peerinvalid Peer @ionic-native/geolocation@5.3.0 wants @ionic-native/core@^5.1.0
npm ERR! peerinvalid Peer @ionic-native/http@5.3.0 wants @ionic-native/core@^5.1.0
npm ERR! peerinvalid Peer @ionic-native/in-app-browser@5.2.0 wants @ionic-native/core@^5.1.0
npm ERR! peerinvalid Peer @ionic-native/launch-navigator@5.11.0 wants @ionic-native/core@^5.1.0
npm ERR! peerinvalid Peer @ionic-native/network@5.3.0 wants @ionic-native/core@^5.1.0
npm ERR! peerinvalid Peer @ionic-native/screen-orientation@5.4.0 wants @ionic-native/core@^5.1.0
npm ERR! peerinvalid Peer @ionic-native/splash-screen@5.0.0 wants @ionic-native/core@5.0.0
npm ERR! peerinvalid Peer @ionic-native/status-bar@5.0.0 wants @ionic-native/core@5.0.0
npm ERR! peerinvalid Peer @ionic-native/vibration@5.7.0 wants @ionic-native/core@^5.1.0

npm ERR! Please include the following file with any support request:
npm ERR! D:\Clients\ionic4\npm-debug.log
[ERROR] An error occurred while running subprocess cordova.

Ionic CLI : 5.1.0 (C:\Users\Sampath\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : @ionic/angular 4.4.0
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.2.3
@angular/cli : 7.2.3
@ionic/angular-toolkit : 1.2.0

Cordova CLI : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : none
Cordova Plugins : no whitelisted plugins (0 plugins total)

cordova-res : not installed
native-run : 0.2.5

NodeJS : v12.4.0 (C:\Program Files\nodejs\node.exe)
npm : 2.15.12
OS : Windows 10

The text was updated successfully, but these errors were encountered:

Источник

cordova-ошибка: не удалось получить платформу android

Я установил cordova и создал новый проект.

но когда я использую эту команду для добавления платформы android:

cordova platfom добавить android

вот как я создал новый проект:

cordova создать hello com.образец.привет это

и это мой менеджер SDK:

Читайте также:  Когда андроид перестанет лагать

Но Я можно добавить платформу ios (но я работаю на Windows)

7 ответов

У меня была такая же проблема с android@5.1.1 версия. Я решил эту проблему, проверив, какая версия android предоставляется cordova. Вы можете проверить это C:/Users/%USER%/.cordova / lib/npm-кэш / Кордова-android

затем вы устанавливаете версию платформы android. Для меня это был @5.1.0, который был в моей папке cordova-android. Поэтому я использовал строку cmd:

платформа cordova добавить android@5.1.0 который должен быть версией differnet для вы.

имел ту же проблему после использования nvm для переключения версии узла. Просто удаление платформы android и переустановка ее работает для меня:

вы можете проверить версию android, предоставленную cordova, введя cordova platform ls внутри папки projectname/cordova. Я ссылался снизу url https://cordova.apache.org/docs/en/latest/guide/platforms/android/.
(Для меня. папка cordova / lib была пуста).

затем добавьте эту платформу из папки cordova проекта, выполнив cordova platform add android@5.1.1 (в моем случае, решена проблема).

кажется, есть ошибка с android@6.2 — . х и позже. У меня была та же проблема, и с помощью приведенного ниже шага удалось создать мой apk.

затем добавьте 6.1.2 специально

также нашел следующее в качестве временного обходного пути

добавить C:\Windows\System32 в конце path в переменных среды, если они не существовали раньше. Затем закрыть cmd и откройте его снова и запустите:

cordova platfom добавить android

в моем случае после стольких попыток, я решил вопрос с помощью следующей команды:

затем я смог добавить платформу и построить свой проект.

Я потратил три дня на этот вопрос

это будет решено, так как я нашел удалить этот dir: C:\Users\win\.Кордова!—3—>

Источник

After upgrading cordova version from 8.x.x to 9.0.0 cordova build is failing #498

Comments

bandhavya commented Jan 1, 2020

Bug Report

On updating the cordova to 9.0.0 version, cordova build is failing with the below error

Problem

Unable to load PlatformApi from platform. Error: Cannot find module ‘properties-parser’ Unhandled error. (The platform «android» does not appear to be a valid cordova platform. It is missing API.js. android not supported.)

What is expected to happen?

What does actually happen?

Information

Command or Code

Environment, Platform, Device

Version information

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

The text was updated successfully, but these errors were encountered:

breautek commented Jan 1, 2020

You may need to also update cordova-android.

You can do so by running the following commands:

cordova platform remove android
cordova platform add android@latest

The latest cordova-android version as of writing is 8.1.0

bandhavya commented Jan 1, 2020

@breautek
I have used cordova-android@8.1.0
Still this issue persists.

brodybits commented Jan 1, 2020

I wonder if something may have gone wrong on your file system (this happened to me once).

I recommend that you try the following:

  • Create a fresh, brand new Cordova project elsewhere in your file system and try running it on Android
  • Then start with a fresh copy of your project elsewhere in your file system, with no plugins or platforms included, then add and run the android platform.

I do think it would be good if Cordova could make this issue easier to troubleshoot (somehow).

bandhavya commented Jan 1, 2020 •

@brodybits , @breautek
I got to know the root cause of this issue.

Читайте также:  Чем открыть айфон от андроида

Steps to replicate :

  1. create a sample cordova app
  2. add platform using ‘cordova platform add android’
  3. cordova build

Build will be successfull. Now go to app folder and check package.json

Next remove platforms, plugins, package.json, package-lock.json, node_modules folders

and try to perform step 2 and 3.
If build passes, then try to delete the above mentioned folders and repeat step 2 and 3.

You will see this issue.
Now check the package.json file

It just contains below json

This json is not including dependencies key, whereas build success contains the dependecies key with cordova-android set in it.

As dependencies is not in the package.json file, cordova build is failing with error
Unable to load PlatformApi from platform. Error: Cannot find module ‘properties-parser’

This issue can be avoid by add cordova-android to dependencies in the package.json
or just by executing cmd line ‘npm install cordova-android@8.0.0’ will add the dependencies to package.json

brodybits commented Jan 1, 2020

The package.json file is now required for Cordova to work.

I think we should update Cordova to check for the required configuration in package.json and show a more useful error message in case it is missing.

bandhavya commented Jan 2, 2020

@brodybits
Yes. Cordova has to handle this

ferrinweb commented Nov 4, 2020

I solved this problem by upgrading the nodejs version to the latest!
The specific reason is that the node version required by fs-extra must be greater than 10.

newuser44 commented Apr 15, 2021

Thanks google— I’m here.
So I have been dealing with for half a day. Upgraded Cordova from 8 to 9.0. I have to manually add I think I’m up to 20 or more modules now.
Both adding and removing needed different modules and now building android is complaining.

Failed to instantiate ProjectBuilder builder: Error: Cannot find module ‘dot-prop’
Cannot find module ‘shebang-regex’
Cannot find module ‘minimatch’
Cannot find module ‘abbrev’

breautek commented Apr 15, 2021

Thanks google— I’m here.
So I have been dealing with for half a day. Upgraded Cordova from 8 to 9.0. I have to manually add I think I’m up to 20 or more modules now.
Both adding and removing needed different modules and now building android is complaining.

Failed to instantiate ProjectBuilder builder: Error: Cannot find module ‘dot-prop’
Cannot find module ‘shebang-regex’
Cannot find module ‘minimatch’
Cannot find module ‘abbrev’

You shouldn’t need to manually add any dependencies, but it is possible that you’re using an out-dated/unsupported version of cordova-android

The latest CLI is version 10, and the latest cordova-android version is 9.1.0. I’d try first upgrading to the latest CLI and then re-adding the cordova-android platform.

If cordova platform remove android doesn’t work for whatever reason, you can do the following:

It’s also recommended to use the latest available release of whatever major of Node you’re using. Refer to the table below:

NodeJS Major Latest Version
10.x 10.24.1
12.x 12.22.1
14.x 14.16.1

Odd major versions of Node (e.g: 11.x, 13.x, 15.x) is not supported. They may or may not work.

There doesn’t appear to be an actual issue here related to cordova-cli other than aforementioned issue with detecting what is a valid cordova project in general to provide better error feedback. There is a ticket for this discussion apache/cordova#155 therefore I’ll be closing this issue.

Источник

ionic cordova platform add — fails to update build.gradle with proper android gradle plugin #947

Comments

nhhockeyplayer commented Apr 9, 2020 •

Bug Report

ionic cordova platform add — fails to update build.gradle with proper android gradle plugin

Problem

causes build to fail

What is expected to happen?

when adding a new plaform, build.gradle should reflect the appropriate android gradle plugin not some hardwired guess like 3.3.0

What does actually happen?

version 3.3.0 is what lands inside the platforms/android/build.gradle instead of 3.6.2 which syncs the gradle version with the version of android studio I am using which is in fact 3.6.2

Information

android studio 3.6.2
gradle version 3.6.4

this is the problem causing builds to fail
android gradle plugin version 3.3.0 (suppose to be 3.6.2 in sync with android studio)

The text was updated successfully, but these errors were encountered:

andalike commented Apr 9, 2020

Go to android folder(platform/android)

go to build.gradle file

Modify the line: dependencies <
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

Do a build and run

raphinesse commented Apr 9, 2020

  • Your messages sound quite rude
  • This is not an ionic support forum or bug tracker
  • If you think you found a problem with Cordova, add the exact commands to reproduce your problem
  • Do not hesitate to edit the actual issue with the relevant information instead of posting comments that correct the previous statements
  • The supported way to build your app is to use Cordova’s CLI (as in cordova build android )

breautek commented Apr 9, 2020

On android studio 3.6.1, I’m able to add and build a simple android cordova project successfully, with the gradle plugin set to version 3.3.0.

I’m currently unable to update to 3.6.2 because this version was just recently released and is currently not in the package repository for my OS. But I’d be pretty surprised if Google would introduce a breaking change in a patch bump.

Cordova doesn’t simply just accept the latest version of its dependencies because you could also run into this exact same type of scenario if dependencies just arbitrary update. Versions are pinned because they have demonstrated repeatedly that version consistently works with the latest versions available at the time of release. Do note that google does not follow traditional semver syntax. The version x.y.z, if x or y changes, they consider that a major release that can include breaking changes. So hard wiring versions is not a bug, it is completely intentional to avoid unintentional breaking changes.

When 3.6.2 releases is propagated to the release channels for my OS, I’ll rerun my tests on version 3.6.2. You may need to ping me in about a week if you don’t see a response. If by the weekend I still don’t see the 3.6.2 update, I’ll just download from the website and install & configure a 3.6.2 environment so that I can test. I just can’t spend the time to do that right now.

In the meantime, couple of potential workarounds I can see are:

Источник

Читайте также:  Вин 11 поддержка андроид
Оцените статью