An error occurred while running cordova build android - gradle

all solution of ionic forum & stackoverflow are tested but no result.
INFO :

global packages:

@ionic/cli-utils : 1.5.0
Cordova CLI      : 7.0.1
Ionic CLI        : 3.5.0

local packages:

@ionic/app-scripts        : 1.3.12
@ionic/cli-plugin-cordova : 1.3.0
Cordova Platforms         : android 6.2.3
Ionic Framework           : ionic-angular 3.3.0

System:

Node       : v6.9.1
OS         : Windows 10
Xcode      : not installed
ios-deploy : not installed
ios-sim    : not installed
npm        : 3.10.8

after eun "ionic cordova build android"


× Running command - failed!

[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova build android (exit code 1):

        ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
        JAVA_HOME=C:\Program Files\java\jdk1.8.0_131
        Subproject Path: CordovaLib
        The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use
        Task.doLast(Action) instead.
        at build_ebnkv43a2dv7jnshh0ewwr23p.run(D:\ws\myapp\platforms\android\build.gradle:137)
        The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
        Incremental java compilation is an incubating feature.
        The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please
        use TaskInputs.file(Object).skipWhenEmpty() instead.
        Checking the license for package Android Support Repository in C:\Program Files
        (x86)\Android\android-sdk\licenses
        Warning: License for package Android Support Repository not accepted.

        BUILD FAILED

        Total time: 15.147 secs

        FAILURE: Build failed with an exception.

        * What went wrong:
        A problem occurred configuring root project 'android'.
        > You have not accepted the license agreements of the following SDK components:
        [Android Support Repository].
        Before building your project, you need to accept the license agreements and complete the installation of the
        missing components using the Android Studio SDK Manager.
        Alternatively, to learn how to transfer the license agreements from one workstation to another, go to
        http://d.android.com/r/studio-ui/export-licenses.html

        * Try:
        Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
        Error: cmd: Command failed with exit code 1 Error output:
        FAILURE: Build failed with an exception.

        * What went wrong:
        A problem occurred configuring root project 'android'.
        > You have not accepted the license agreements of the following SDK components:
        [Android Support Repository].
        Before building your project, you need to accept the license agreements and complete the installation of the
        missing components using the Android Studio SDK Manager.
        Alternatively, to learn how to transfer the license agreements from one workstation to another, go to
        http://d.android.com/r/studio-ui/export-licenses.html

        * Try:
        Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


this is my sdk manager


system envirememnt

CONFIG.XML
i try to build with this not working then i remove it its the same resault

    <preference name="android-minSdkVersion" value="24"/>

i try many many solution but no result
i hope ionic team help me or someone
thank you

Did you read the error message?

Your screenshot doesn’t look like the current SDK Manager of Android Studio.
How are you starting it?

If you upgrade this your ionic info will get a lot more useful for Android dev.

yes i read, and i resolve the problem before but not the solution i try before not work now
===> old solution is to install latest android sdk

As it says in the error message, the solution is to use the Android Studio SDK Manager to accept the licence agreements.

so i use sdk manager, and know should i use android studio to manage sdks and to accept the licence agreements.

this is step to follow to setup great environment :

  • install java jdk and add path to environment variable
    image
  • install git and add it to path
  • install nodejs
  • install cordova : https://cordova.apache.org/docs/en/latest/guide/platforms/android/ then add cordova location to path in environment variable
  • install ionic : check doc
  • install gradle and add gradle location to path in environment variable
  • install android studio
    image
    thats it. and thank you ionic team :slight_smile: