# Error building android with ionic 4 and cordova

**URL:** <https://forum.ionicframework.com/t/error-building-android-with-ionic-4-and-cordova/147790>\
**Category:** ionic-v3\
**Created:** [November 16, 2018, 7:38pm UTC](https://forum.ionicframework.com/t/error-building-android-with-ionic-4-and-cordova/147790 "2018-11-16T19:38:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsmythe](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@jsmythe](https://forum.ionicframework.com/u/jsmythe)\
**Post date:** [November 16, 2018, 7:38pm UTC](https://forum.ionicframework.com/t/error-building-android-with-ionic-4-and-cordova/147790/1 "2018-11-16T19:38:16Z")

</div>

I entered  
ionic start tabsCordova tabs --cordova --type=angular --no-git  
ionic cordova build android

and had an error. (see below for excerpts) I am using npm 6.4.1, ionic 4.3.1 and cordova 8.1.2 on a mac with High Sierra. Android Studio has a Project Structure with gradle version 4.6 and android plugin version 3.2.1.

1. Why does it download …/gradle-4.1-all.zip and then download …/gradle/3.0.1/gradle-3.0.1.pom and related?
2. Why is it looking for NDK toolchains folder for ABI with prefix: mips64el-linux-android?

…

> cordova build android  
> Android Studio project detected  
> ANDROID\_HOME=/Users/jsmythe/Library/Android/sdk  
> JAVA\_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0\_112.jdk/Contents/Home  
> studio  
> Subproject Path: CordovaLib  
> Subproject Path: app  
> Downloading [https://services.gradle.org/distributions/gradle-4.1-all.zip](https://services.gradle.org/distributions/gradle-4.1-all.zip)

…

Unzipping /Users/jsmythe/.gradle/wrapper/dists/gradle-4.1-all/bzyivzo6n839fup2jbap0tjew/gradle-4.1-all.zip to /Users/jsmythe/.gradle/wrapper/dists/gradle-4.1-all/bzyivzo6n839fup2jbap0tjew  
Set executable permissions for: /Users/jsmythe/.gradle/wrapper/dists/gradle-4.1-all/bzyivzo6n839fup2jbap0tjew/gradle-4.1/bin/gradle  
Starting a Gradle Daemon (subsequent builds will be faster)  
Download [https://maven.google.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom](https://maven.google.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom)  
Download [https://maven.google.com/com/android/tools/build/gradle-core/3.0.1/gradle-core-3.0.1.pom](https://maven.google.com/com/android/tools/build/gradle-core/3.0.1/gradle-core-3.0.1.pom)  
Download [https://maven.google.com/com/android/tools/build/builder/3.0.1/builder-3.0.1.pom](https://maven.google.com/com/android/tools/build/builder/3.0.1/builder-3.0.1.pom)  
Download [https://maven.google.com/com/android/tools/lint/lint/26.0.1/lint-26.0.1.pom](https://maven.google.com/com/android/tools/lint/lint/26.0.1/lint-26.0.1.pom)  
Download [https://maven.google.com/com/android/tools/build/gradle-api/3.0.1/gradle-api-3.0.1.pom](https://maven.google.com/com/android/tools/build/gradle-api/3.0.1/gradle-api-3.0.1.pom)  
…

FAILURE: Build failed with an exception.

- What went wrong:  
A problem occurred configuring project ‘:CordovaLib’.

> No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

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

- Get more help at [https://help.gradle.org](https://help.gradle.org)

BUILD FAILED in 2m 24s  
/Users/jsmythe/ionic/tabsCordova/platforms/android/gradlew: Command failed with exit code 1 Error output:  
FAILURE: Build failed with an exception.

- What went wrong:  
A problem occurred configuring project ‘:CordovaLib’.

> No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

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

- Get more help at [https://help.gradle.org](https://help.gradle.org)

BUILD FAILED in 2m 24s  
[**ERROR**] **An error occurred while running subprocess**  **cordova**  **.**

cordova build android exited with exit code 1.

Re-running this command with the --verbose flag may provide more information.

---

<div class="post-metadata">

**Author:** ![jsmythe](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@jsmythe](https://forum.ionicframework.com/u/jsmythe)\
**Post date:** [November 16, 2018, 8:46pm UTC](https://forum.ionicframework.com/t/error-building-android-with-ionic-4-and-cordova/147790/2 "2018-11-16T20:46:07Z")

</div>

I just found several entries in 4 of the android files that seem to explain why the build is looking for old versions of gradle. Why is the gradle version in Android Studio ignored?. Is this a bug???

tabsCordova/platforms/android/build.gradle:  
classpath ‘com.android.tools.build:gradle:3.0.1’

tabsCordova/platforms/android/app/build.gradle:  
classpath ‘com.android.tools.build:gradle:3.0.1’  
gradleVersion = ‘4.1.0’

tabsCordova/platforms/android/CordovaLib/build.gradle:  
classpath ‘com.android.tools.build:gradle:3.0.1’

tabsCordova/platforms/android/gradle/wrapper/gradle-wrapper.properties:  
distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip

---

<div class="post-metadata">

**Author:** ![jsmythe](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@jsmythe](https://forum.ionicframework.com/u/jsmythe)\
**Post date:** [November 17, 2018, 4:09pm UTC](https://forum.ionicframework.com/t/error-building-android-with-ionic-4-and-cordova/147790/3 "2018-11-17T16:09:04Z")

</div>

I changed 3.0.1 to 3.2.1, 4.1.0 to 4.6.0 and 4.1 to 4.6 and had another error. There is no /Users/jsmythe/Ionic/tabsCordova/gradle/ folder and a directory /Users/jsmythe/Ionic/tabsCordova/platforms/android/gradle/4.1 is created. In addition, /Users/jsmythe/Ionic/tabsCordova/platforms/android/gradle/wrapper/gradle-wrapper.properties is changed back to gradle-4.1-all.zip.

…

FAILURE: Build failed with an exception.

- Where:  
Build file ‘/Users/jsmythe/Ionic/tabsCordova/platforms/android/CordovaLib/build.gradle’ line: 40

- What went wrong:  
A problem occurred evaluating project ‘:CordovaLib’.  
\> Failed to apply plugin [id ‘com.android.library’]  
\> Minimum supported Gradle version is 4.6. Current version is 4.1. If using the gradle wrapper, try editing the distributionUrl in /Users/jsmythe/Ionic/tabsCordova/gradle/wrapper/gradle-wrapper.properties to gradle-4.6-all.zip

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

- Get more help at [https://help.gradle.org](https://help.gradle.org)

BUILD FAILED in 2s  
/Users/jsmythe/ionic/tabsCordova/platforms/android/gradlew: Command failed with exit code 1 Error output:  
FAILURE: Build failed with an exception.

- Where:  
Build file ‘/Users/jsmythe/Ionic/tabsCordova/platforms/android/CordovaLib/build.gradle’ line: 40

- What went wrong:  
A problem occurred evaluating project ‘:CordovaLib’.  
\> Failed to apply plugin [id ‘com.android.library’]  
\> Minimum supported Gradle version is 4.6. Current version is 4.1. If using the gradle wrapper, try editing the distributionUrl in /Users/jsmythe/Ionic/tabsCordova/gradle/wrapper/gradle-wrapper.properties to gradle-4.6-all.zip

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

- Get more help at [https://help.gradle.org](https://help.gradle.org)

BUILD FAILED in 2s  
[**ERROR**] **An error occurred while running subprocess**  **cordova**  **.**

cordova build android exited with exit code 1.

Re-running this command with the --verbose flag may provide more information.

---

<div class="post-metadata">

**Author:** ![jsmythe](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@jsmythe](https://forum.ionicframework.com/u/jsmythe)\
**Post date:** [November 17, 2018, 4:43pm UTC](https://forum.ionicframework.com/t/error-building-android-with-ionic-4-and-cordova/147790/4 "2018-11-17T16:43:08Z")

</div>

I just found 2 files called GradleBuilder.js and StudioBuilder.js in  
tabsCordova/platforms/android/cordova/lib/builders  
with  
var distributionUrl = process.env[‘CORDOVA\_ANDROID\_GRADLE\_DISTRIBUTION\_URL’] || ‘https\://services.gradle.org/distributions/gradle-4.1-all.zip’;  
and changed 4.1 to 4.6. I was able to build  
tabsCordova/platforms/android/app/build/outputs/apk/debug/app-debug.apk

---

<div class="post-metadata">

**Author:** ![codiqa100078139](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/codiqa100078139/32/115905_2.png) [@codiqa100078139](https://forum.ionicframework.com/u/codiqa100078139)\
**Post date:** [November 26, 2018, 3:30pm UTC](https://forum.ionicframework.com/t/error-building-android-with-ionic-4-and-cordova/147790/5 "2018-11-26T15:30:22Z")

</div>

Same problem for me  
Same error

---

<div class="post-metadata">

**Author:** ![Podum](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/podum/32/126357_2.png) [@Podum](https://forum.ionicframework.com/u/Podum)\
**Post date:** [March 2, 2019, 3:00am UTC](https://forum.ionicframework.com/t/error-building-android-with-ionic-4-and-cordova/147790/6 "2019-03-02T03:00:17Z")

</div>

Same… I think the culprit is somewhere in this line  
 ![image](https://global.discourse-cdn.com/ionicframework/original/3X/8/c/8cd25b75efe8b02e4f875fd27117a7c3404292d3.png)

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:09pm UTC](https://forum.ionicframework.com/t/error-building-android-with-ionic-4-and-cordova/147790/7 "2021-07-19T21:09:25Z")

</div>

Closed on July 19, 2021, 9:09pm UTC


