'Could not find method android() for arguments [before_plugins_] on root project 'xyz' of type org.gradle.api.Project

Having issue when running the nativescript android application on my device. Could not find method android() for arguments [before_plugins_d5qrcua3za3scd760qug60fz6$_run_closure1@5754ca71] on root project 'xyz' of type org.gradle.api.Project. How to overcome this issue?

before-plugins.gradle:

android {  
  project.ext {
      googlePlayServicesVersion = "15.0.0"
  }
} 

package.json:

{
  "name": "xyz",
  "main": "./src/main.ts",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "@angular/animations": "~13.1.1",
    "@angular/common": "~13.1.1",
    "@angular/compiler": "~13.1.1",
    "@angular/core": "~13.1.1",
    "@angular/forms": "~13.1.1",
    "@angular/http": "^7.2.16",
    "@angular/platform-browser": "~13.1.1",
    "@angular/platform-browser-dynamic": "~13.1.1",
    "@angular/router": "~13.1.1",
    "@mashdog/nativescript-accordion": "^7.0.6",
    "@nativescript/angular": "^13.0.0",
    "@nativescript/core": "^8.2.1",
    "@nativescript/firebase": "^11.1.3",
    "@nativescript/geolocation": "^8.0.2",
    "@nativescript/iqkeyboardmanager": "^2.0.0",
    "@nativescript/theme": "~3.0.1",
    "@nstudio/nativescript-checkbox": "^2.0.4",
    "@nstudio/nativescript-loading-indicator": "^4.1.2",
    "@triniwiz/nativescript-youtubeplayer": "^4.1.4",
    "nativescript-drop-down": "^6.0.0",
    "nativescript-feedback": "^2.0.0",
    "nativescript-phone": "^3.0.2",
    "nativescript-ripple": "^4.0.1",
    "nativescript-store-ratings": "^1.0.0",
    "nativescript-theme-core": "^2.0.24",
    "nativescript-ui-listview": "^10.0.2",
    "rxjs": "~7.4.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^13.1.1",
    "@angular/compiler-cli": "~13.1.1",
    "@nativescript/android": "8.2.2",
    "@nativescript/ios": "8.2.1",
    "@nativescript/types": "~8.1.1",
    "@nativescript/webpack": "~5.0.0",
    "@ngtools/webpack": "^13.1.1",
    "typescript": "4.4.4"
  }
}

error message: Click here to see error image



Solution 1:[1]

I had the same issue. After looking at the updated Nativescript documentation, I changed my before-plugins.gradle to something liked this to get it to build.

ext {
  googlePlayServicesVersion = "15.0.0"
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kyle