Error building android with ionic 4 and cordova


#1

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

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
Download 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
Download 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

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

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

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.


#2

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


#3

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

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

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.


#4

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


#5

Same problem for me
Same error