'The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead

I have created an blank project and successfully build and run in my device

but when i add this plugin ionic cordova plugin add cordova-plugin-geofence and give ionic cordova run android i am getting the error as

i have not written any code

below



Solution 1:[1]

You gotta open your Andoroid SDK Manager and install the following components as mentioned in the error:

  1. SDK Patch Applier V4
  2. Google repositoty
  3. Android Support Library

Solution 2:[2]

Just to clarify, I changed my package.json to:

"cordova-android": "6.2.0",

which fixed the problem for me.

Solution 3:[3]

go to ionic_folder/platforms/android/build.gradle

If you see this lines of code in your file

buildscript {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }

    }
Change the order of the executions

  buildscript {
    repositories {

        maven {
            url "https://maven.google.com"
        }
        jcenter()

    }
Then go again and run your application by doing ionic cordova run android

Solution 4:[4]

Change the Package.json file

"cordova-android": "6.2.0"

Solution 5:[5]

getting same problem in ionic 5 build and solved by running the following commands

cordova clean android
cordova plugin add cordova-android-support-gradle-release

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 Gandhi
Solution 2 Anand_5050
Solution 3 Anand_5050
Solution 4 Sumant Singh
Solution 5 kautikmistry