簡體   English   中英

錯誤:ENOENT:運行 Ionic Cordova Platform Add Android 時沒有這樣的文件或目錄

[英]Error: ENOENT: no such file or directory when running Ionic Cordova Platform Add Android

我只是不知道如何解決這個問題。 我嘗試了很多解決方案,但對我的情況沒有任何作用。 所以我將我的項目放在xampp\htdocs中,文件夾名稱為exam-ionic

然后當我嘗試添加平台 android 時出現錯誤

Error: ENOENT: no such file or directory, 
 open 'c:\xampp\htdocs\exam-ionic\android\package.json'] {
 errno: -4058,
 code: 'ENOENT',
 syscall: 'open',
 path: 'c:/xampp/htdocs/exam-ionic/android/package.json

這是當我運行ionic cordova platform add android --verbose

ionic:utils-process onBeforeExit handler: 'process.exit' received +0ms
ionic:utils-process onBeforeExit handler: running 1 functions +2ms
ionic:utils-process error while killing process tree for 6724: Error: Command 
failed: taskkill /pid 
6724 /T /F
ionic:utils-process ERROR: The process "6724" not found.
ionic:utils-process
ionic:utils-process     at ChildProcess.exithandler (child_process.js:308:12)
ionic:utils-process     at ChildProcess.emit (events.js:315:20)
ionic:utils-process     at maybeClose (internal/child_process.js:1048:16)
ionic:utils-process     at Process.ChildProcess._handle.onexit 
(internal/child_process.js:288:5) {
ionic:utils-process   killed: false,
ionic:utils-process   code: 128,
ionic:utils-process   signal: null,
ionic:utils-process   cmd: 'taskkill /pid 6724 /T /F'
ionic:utils-process } +916ms
ionic:utils-process onBeforeExit handler: error from function: Error: Command 
failed: taskkill /pid 
6724 /T /F
ionic:utils-process ERROR: The process "6724" not found.
ionic:utils-process
ionic:utils-process     at ChildProcess.exithandler (child_process.js:308:12)
ionic:utils-process     at ChildProcess.emit (events.js:315:20)
ionic:utils-process     at maybeClose (internal/child_process.js:1048:16)
ionic:utils-process     at Process.ChildProcess._handle.onexit 
(internal/child_process.js:288:5) {
ionic:utils-process   killed: false,
ionic:utils-process   code: 128,
ionic:utils-process   signal: null,
ionic:utils-process   cmd: 'taskkill /pid 6724 /T /F'
ionic:utils-process } +3ms
ionic:utils-process processExit: exiting (exit code: 1) +5ms

這是我的離子信息

Ionic:

Ionic CLI                     : 5.4.16 
(C:\Users\User\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework               : @ionic/angular 5.6.0
@angular-devkit/build-angular : 0.1101.4
@angular-devkit/schematics    : 11.1.4
@angular/cli                  : 11.1.4
@ionic/angular-toolkit        : 3.1.0

Capacitor:

Capacitor CLI   : 2.4.7
@capacitor/core : 2.4.7

Cordova:

Cordova CLI       : 10.0.0
Cordova Platforms : none
Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin- 
ionic-webview 4.2.1, (and 9 other plugins)

Utility:

cordova-res : 0.15.3
native-run  : 1.3.0

System:

Android SDK Tools : 26.1.1 (C:\Users\User\AppData\Local\Android\Sdk)
NodeJS            : v14.16.1 (C:\Program Files\nodejs\node.exe)
npm               : 7.9.0
OS                : Windows 10

這是 package.json

{
  "name": "exam-ionic",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "~11.2.0",
    "@angular/core": "~11.2.0",
    "@angular/forms": "~11.2.0",
    "@angular/platform-browser": "~11.2.0",
    "@angular/platform-browser-dynamic": "~11.2.0",
    "@angular/router": "~11.2.0",
    "@capacitor/android": "^2.4.7",
    "@capacitor/core": "2.4.7",
    "@ionic-native/core": "^5.32.0",
    "@ionic-native/onesignal": "^5.32.0",
    "@ionic-native/wonderpush": "^5.32.0",
    "@ionic/angular": "^5.5.2",
    "@ionic/storage": "^2.3.1",
    "cordova-plugin-androidx": "^3.0.0",
    "cordova-plugin-androidx-adapter": "^1.1.3",
    "cordova-sqlite-storage": "^5.1.0",
    "ionic-context-menu": "^5.0.0",
    "onesignal-cordova-plugin": "^2.11.3",
    "rxjs": "~6.6.0",
    "tslib": "^2.0.0",
    "wonderpush-cordova-sdk": "^3.0.3",
    "wonderpush-cordova-sdk-fcm": "^1.0.1",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1101.4",
    "@angular/cli": "~11.1.4",
    "@angular/compiler": "~11.2.0",
    "@angular/compiler-cli": "~11.2.0",
    "@angular/language-service": "~11.2.0",
    "@capacitor/cli": "2.4.7",
    "@ionic/angular-toolkit": "^3.1.0",
    "@ionic/lab": "3.2.10",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-ionic-webview": "^4.2.1",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.2.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~4.0.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-sqlite-storage": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-ionic-keyboard": {},
      "onesignal-cordova-plugin": {},
      "wonderpush-cordova-sdk": {
        "CLIENT_ID": "a312c22bafed82635f3167cc71a7437a9b840c44",
        "CLIENT_SECRET": "e499dc98a572d63752da6b73494ff8bf3bc99cf04a64bfc5451fbdce52854547"
      },
      "wonderpush-cordova-sdk-fcm": {
        "CLIENT_ID": "a312c22bafed82635f3167cc71a7437a9b840c44",
        "CLIENT_SECRET": "e499dc98a572d63752da6b73494ff8bf3bc99cf04a64bfc5451fbdce52854547",
        "SENDER_ID": "default"
      },
      "cordova-plugin-androidx": {},
      "cordova-plugin-androidx-adapter": {}
    },
    "platforms": []
  }
}

I've tried reinstall the npm, reinstall the cordova, updated the ionic CLI, deleted node_module folder + package.lock.json then npm install , but nothing does work. 請幫助meeee

我正在運行同樣的錯誤,今天我找到了解決方案。 以前嘗試過一個電容插件,但是我的項目是cordova,所以從項目中去掉了。 但我認為有些文件沒有被正確刪除,當我運行離子修復時,問題就開始了。 因此,為了修復這個問題,我刪除了項目根目錄下的 ANDROID 文件夾,根目錄下與電容器相關的所有文件,編輯了 package.json 並刪除了與電容器相關的所有內容,一切正常。

解決方案

  1. 刪除項目根目錄下的android文件夾
  2. 編輯package.json並刪除與Capacitor相關的所有內容

在我的情況下,我的根目錄中有 android 文件夾,這是我從平台文件夾中復制的。 所以當我將它從 android 重命名為 android-out 並運行 ionic cordova platfrom add android 它工作

我在 android 文件夾中遇到了同樣的問題。 我解決了它: - 我的離子版本是 5.4.0

  1. 手動刪除 platform/android 文件夾

  2. 運行以下命令:

  3. 離子 cordova rm android

  4. 離子 cordova 添加 android

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM