apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

error updating cordova in ionic project #1658

Closed pedro21900 closed 7 months ago

pedro21900 commented 8 months ago

No matter what I do or what I update I always come back to this error and I need to update the project to deploy in the play store

ionic cordova platform add android@10
> cordova platform add android@10
Using cordova-fetch for cordova-android@10
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms/android
        Package: br.xx.xxx.xxxx.xx
        Name: xxx
        Activity: MainActivity
        Android target: android-30
ENOENT: no such file or directory, mkdir 'platforms/android/app/src/main'

{
  "name": "xxx-app-v4",
  "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": "^8.1.2",
    "@angular/core": "^8.1.2",
    "@angular/forms": "^8.1.2",
    "@angular/http": "^7.2.2",
    "@angular/platform-browser": "^8.1.2",
    "@angular/platform-browser-dynamic": "^8.1.2",
    "@angular/router": "^8.1.2",
    "@ionic-native/action-sheet": "^5.17.1",
    "@ionic-native/android-permissions": "^5.7.0",
    "@ionic-native/app-version": "^5.17.1",
    "@ionic-native/background-geolocation": "^5.6.1",
    "@ionic-native/background-mode": "^5.12.0",
    "@ionic-native/barcode-scanner": "^5.6.1",
    "@ionic-native/base64": "^5.8.0",
    "@ionic-native/camera": "^5.6.1",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/device": "^5.6.1",
    "@ionic-native/diagnostic": "^5.27.0",
    "@ionic-native/dialogs": "^5.12.0",
    "@ionic-native/file": "^5.7.0",
    "@ionic-native/file-transfer": "^5.7.0",
    "@ionic-native/geolocation": "^5.6.1",
    "@ionic-native/ionic-webview": "^5.27.0",
    "@ionic-native/launch-navigator": "^5.6.1",
    "@ionic-native/location-accuracy": "^5.27.0",
    "@ionic-native/network": "^5.6.1",
    "@ionic-native/photo-viewer": "^5.6.1",
    "@ionic-native/social-sharing": "^5.12.0",
    "@ionic-native/splash-screen": "^5.0.0",
    "@ionic-native/sqlite-db-copy": "^5.8.0",
    "@ionic-native/status-bar": "^5.6.1",
    "@ionic/angular": "^4.7.1",
    "@ionic/storage": "^2.2.0",
    "@mauron85/cordova-plugin-background-geolocation": "3.0.3",
    "@types/crypto-js": "^3.1.43",
    "br-mask": "0.0.7",
    "com-badrit-base64": "0.2.0",
    "com-sarriaroman-photoviewer": "1.2.2",
    "cordova-android": "^10.1.2",
    "cordova-android-support-gradle-release": "^3.0.0",
    "cordova-ios": "^5.1.1",
    "cordova-pdf-generator": "^2.0.8",
    "cordova-plugin-actionsheet": "2.3.3",
    "cordova-plugin-add-swift-support": "2.0.2",
    "cordova-plugin-android-permissions": "1.0.0",
    "cordova-plugin-androidx": "^3.0.0",
    "cordova-plugin-androidx-adapter": "1.1.1",
    "cordova-plugin-app-version": "^0.1.9",
    "cordova-plugin-background-mode": "0.7.3",
    "cordova-plugin-camera": "4.0.3",
    "cordova-plugin-dbcopy": "2.1.2",
    "cordova-plugin-dialogs": "2.0.1",
    "cordova-plugin-file": "6.0.1",
    "cordova-plugin-file-transfer": "1.7.1",
    "cordova-plugin-geolocation": "4.0.1",
    "cordova-plugin-mauron85-background-geolocation": "^3.0.1",
    "cordova-plugin-network-information": "2.0.1",
    "cordova-plugin-request-location-accuracy": "2.3.0",
    "cordova-plugin-x-socialsharing": "5.4.7",
    "cordova-sqlite-storage": "6.0.0",
    "core-js": "^2.5.4",
    "crypto-js": "^3.1.9-1",
    "es6-promise-plugin": "4.2.2",
    "isiigo-cordova-plugin-printer": "^1.0.4",
    "ng-lazyload-image": "^6.0.0",
    "phonegap-plugin-barcodescanner": "8.0.1",
    "rxjs": "~6.6.7",
    "tslib": "^1.9.0",
    "uk.co.workingedge.phonegap.plugin.launchnavigator": "5.0.4",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/architect": "~0.801.2",
    "@angular-devkit/build-angular": "~0.801.2",
    "@angular-devkit/core": "~8.1.2",
    "@angular-devkit/schematics": "~8.1.2",
    "@angular/cli": "~8.1.2",
    "@angular/compiler": "~8.1.2",
    "@angular/compiler-cli": "~8.1.2",
    "@angular/language-service": "~8.1.2",
    "@ionic/angular-toolkit": "^2.1.1",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~12.0.0",
    "codelyzer": "~4.5.0",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-ionic-keyboard": "^2.1.3",
    "cordova-plugin-ionic-webview": "^4.0.1",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.5",
    "cordova.plugins.diagnostic": "^7.1.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~8.1.0",
    "tslint": "~5.16.0",
    "typescript": "~3.4.5"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-mauron85-background-geolocation": {
        "GOOGLE_PLAY_SERVICES_VERSION": "11+",
        "ANDROID_SUPPORT_LIBRARY_VERSION": "26+",
        "ICON": "@mipmap/ic_launcher",
        "SMALL_ICON": "@mipmap/ic_launcher",
        "ACCOUNT_NAME": "@string/app_name",
        "ACCOUNT_LABEL": "@string/app_name",
        "ACCOUNT_TYPE": "$PACKAGE_NAME.account",
        "CONTENT_AUTHORITY": "$PACKAGE_NAME",
        "ALWAYS_USAGE_DESCRIPTION": "This app always requires location tracking",
        "MOTION_USAGE_DESCRIPTION": "This app requires motion detection"
      },
      "cordova-plugin-geolocation": {},
      "cordova-android-support-gradle-release": {
        "ANDROID_SUPPORT_VERSION": "27.+"
      },
      "cordova-plugin-network-information": {},
      "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": {},
      "phonegap-plugin-barcodescanner": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      },
      "uk.co.workingedge.phonegap.plugin.launchnavigator": {
        "GOOGLE_API_KEY_FOR_ANDROID": "AIzaSyBlBkfwux61wWMZj9VYoFjrQc-4UljITY4",
        "OKHTTP_VERSION": "3.12.0",
        "LOCATION_USAGE_DESCRIPTION": "This app requires access to your location for navigation purposes"
      },
      "cordova-plugin-camera": {},
      "com-sarriaroman-photoviewer": {},
      "cordova-plugin-file-transfer": {},
      "cordova-plugin-file": {},
      "cordova-plugin-android-permissions": {},
      "cordova-plugin-dbcopy": {},
      "cordova-sqlite-storage": {},
      "com-badrit-base64": {},
      "cordova-plugin-x-socialsharing": {
        "ANDROID_SUPPORT_V4_VERSION": "24.1.1+"
      },
      "cordova-pdf-generator": {},
      "cordova-plugin-dialogs": {},
      "cordova-plugin-background-mode": {},
      "cordova-plugin-app-version": {},
      "cordova-plugin-actionsheet": {},
      "cordova-plugin-request-location-accuracy": {
        "PLAY_SERVICES_LOCATION_VERSION": "16.+"
      },
      "cordova-plugin-androidx": {},
      "cordova-plugin-androidx-adapter": {},
      "cordova.plugins.diagnostic": {
        "ANDROIDX_VERSION": "1.0.0",
        "ANDROIDX_APPCOMPAT_VERSION": "1.3.1"
      }
    },
    "platforms": [
      "ios"
    ]
  }
}
breautek commented 8 months ago

cordova-android@10 is out of support. The current version is cordova-android@12, which uses API 33, which is what is required to deploy to Google Play. So the first thing I'd try is try to use cordova-android@12 instead of 10.

If you still see ENOENT: no such file or directory, mkdir 'platforms/android/app/src/main'

it suggest that the folder structure isn't being generated as expected. To remove influence from frameworks, I'd try to see if you can reproduce the issue in a sample cordova app without the use of frameworks.

cordova create testapp
cd testapp
cordova platform add android@12 --verbose

If it fails, please post the output of the cordova platform add android@12 --verbose command. If it works successfully, then it suggests an issue inside the Ionic CLI.

Please let me know what is found.

pedro21900 commented 7 months ago

após uma tentativa utilizando "cordova platform add android@12 --verbose"

I got the following error

node version v10.9.0 angular 8 ionic 4

No scripts found for hook "before_platform_add". Using cordova-fetch for cordova-android@12 fetch: Installing cordova-android@12 to /home/xxxxx/git/xxx-app/02_fontes Running command: npm install cordova-android@12 --production --save Command finished with error code 0: npm install,cordova-android@12,--production,--save Removing "cordova-" prefix from cordova-android Adding android project... Unable to load PlatformApi from platform. SyntaxError: Unexpected token . Unhandled error. (The platform "android" does not appear to be a valid cordova platform. It is missing API.js. android not supported.) Error [ERR_UNHANDLED_ERROR]: Unhandled error. (The platform "android" does not appear to be a valid cordova platform. It is missing API.js. android not supported.) at CordovaEventEmitter.emit (events.js:171:17) at CordovaEventEmitter.emit (/home/lenonn/.nvm/versions/node/v10.9.0/lib/node_modules/cordova/node_modules/cordova-common/src/events.js:69:22) at Object.getPlatformApiFunction (/home/xxxxx/.nvm/versions/node/v10.9.0/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/util.js:384:20) at /home/xxxxx/.nvm/versions/node/v10.9.0/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/platform/addHelper.js:181:52

breautek commented 7 months ago

node version v10.9.0

This isn't a supported Node Version. Current LTS is recommended (Node 18), but at minimum you'll need NodeJS 16.13.0

Closing as not a bug.

pedro21900 commented 7 months ago

Thank you very much for the information, thanks to your help I was able to carry out the update, of course I also have to update the plugins, but thanks to your help I am using API 33