Ionic-framework: Gradle Build issue

Created on 23 Oct 2018  路  17Comments  路  Source: ionic-team/ionic-framework

I am facing Gradle Build Issue in ionic cordova build android --prod, please help

I am using gradleVersion 4.1.0

Environment:
Ionic version : 4.2.1

getting error at compile "com.android.support:support-v4:+"

ERROR Log:

FAILURE: Build failed with an exception.

triage

Most helpful comment

i faced the same issue today, it was basically that gradle was not able to find this dependency.
So in order to resolve it i changed the following things in build.gradle files. There are two build.gradle files in ionic project.
change the order of repositories in both of them, take jcenter() to the bottom and add google() to the top and issue gets resolved, build successfully.

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

allprojects {
repositories {
mavenCentral();
google();
jcenter()
}
}

All 17 comments

Same issue here!

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find support-v4.aar (com.android.support:support-v4:26.1.0).
  Searched in the following locations:
      https://jcenter.bintray.com/com/android/support/support-v4/26.1.0/support-v4-26.1.0.aar

I had the same issue today.
After removing and adding the platform script tried to fetch that package again - successfully.

I tried removing and adding the platform again, but still having the same issue.

Yesterday my code works fine, but now I have the same Issue!
I have not updated anything. I don麓t understand
ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
Android SDK Tools : 26.1.1

It looks like this is an issue with JCenters Bintray artefact mirror as the artefact is acutally available in Googles Repository:
https://maven.google.com/com/android/support/support-v4/26.1.0/support-v4-26.1.0.aar

Facing the same issue here for debug builds.
This started happening right after maven downloaded updates during a build for the com.android.support library.
Here is a snippet of the ionic cordova build android --verbose output:

  • What went wrong:

Could not resolve all files for configuration ':app:debugCompileClasspath'.

Could not find support-v4.aar (com.android.support:support-v4:27.1.1).
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/support-v4/27.1.1/support-v4-27.1.1.aar
Could not find support-vector-drawable.aar (com.android.support:support-vector-drawable:27.1.1).
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/support-vector-drawable/27.1.1/support-vector-drawable-27.1.1.aar
Could not find livedata-core.aar (android.arch.lifecycle:livedata-core:1.1.0).
Searched in the following locations:
https://jcenter.bintray.com/android/arch/lifecycle/livedata-core/1.1.0/livedata-core-1.1.0.aar
Could not find viewmodel.aar (android.arch.lifecycle:viewmodel:1.1.0).
Searched in the following locations:
https://jcenter.bintray.com/android/arch/lifecycle/viewmodel/1.1.0/viewmodel-1.1.0.aar
Could not find runtime.aar (android.arch.core:runtime:1.1.0).
Searched in the following locations:
https://jcenter.bintray.com/android/arch/core/runtime/1.1.0/runtime-1.1.0.aar

I have some problem too.

when i build android ,

==========================
1 actionable task: 1 executed
Subproject Path: CordovaLib
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
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_99qz9mnm558puxf3ll78adnly.run(/Users/wuxiran/Development/5.1/56nrs.ipp.mobile.ionic/platforms/android/build.gradle:143)
Configuration 'compile' in project ':' is deprecated. Use 'implementation' instead.
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
:preBuild UP-TO-DATE
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:checkDebugManifest
:CordovaLib:processDebugManifest

===========================================
it will wait in this too long. It took me 2h wait it print some issues .

some log

=========================

Could not resolve com.android.support:support-v4:27.+.
Required by:
project :
Could not resolve com.android.support:support-v4:27.+.
Failed to list versions for com.android.support:support-v4.
Unable to load Maven meta-data from https://jcenter.bintray.com/com/android/support/support-v4/maven-metadata.xml.
Could not HEAD 'https://jcenter.bintray.com/com/android/support/support-v4/maven-metadata.xml'.
Connect to 127.0.0.1:1086 [/127.0.0.1] failed: Connection refused
Could not resolve com.android.support:support-v4:27.+.
Failed to list versions for com.android.support:support-v4.
Unable to load Maven meta-data from https://maven.google.com/com/android/support/support-v4/maven-metadata.xml.
Could not HEAD 'https://maven.google.com/com/android/support/support-v4/maven-metadata.xml'.
Connect to 127.0.0.1:1086 [/127.0.0.1] failed: Connection refused
Could not resolve com.android.support:support-v4:27.+.
Failed to list versions for com.android.support:support-v4.
Unable to load Maven meta-data from https://maven.google.com/com/android/support/support-v4/maven-metadata.xml.
Could not HEAD 'https://maven.google.com/com/android/support/support-v4/maven-metadata.xml'.
Connect to 127.0.0.1:1086 [/127.0.0.1] failed: Connection refused
Could not resolve com.android.support:support-v4:27.+.
Failed to list versions for com.android.support:support-v4.
Unable to load Maven meta-data from https://jcenter.bintray.com/com/android/support/support-v4/maven-metadata.xml.
Could not HEAD 'https://jcenter.bintray.com/com/android/support/support-v4/maven-metadata.xml'.
Connect to 127.0.0.1:1086 [/127.0.0.1] failed: Connection refused

  • 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 1h 55m 11s
at ChildProcess.whenDone (/Users/wuxiran/Development/5.1/56nrs.ipp.mobile.ionic/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:915:16)
at Socket.stream.socket.on (internal/child_process.js:336:11)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at Pipe._handle.close [as _onclose] (net.js:561:12)
(node:2803) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2803) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

==============================

ionic info


Ionic:

ionic (Ionic CLI) : 4.2.1

System:

NodeJS : v8.12.0
npm : 6.4.1
OS : macOS High Sierra


i have'n reinstall gradle4.1.0-all but it doesn't work.

i faced the same issue today, it was basically that gradle was not able to find this dependency.
So in order to resolve it i changed the following things in build.gradle files. There are two build.gradle files in ionic project.
change the order of repositories in both of them, take jcenter() to the bottom and add google() to the top and issue gets resolved, build successfully.

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

allprojects {
repositories {
mavenCentral();
google();
jcenter()
}
}

@AghaAliAbbasKhan You sir, are a legend! How did you manage to determine this?

Actually I have tried repositories google() also, but it doesn't work work earlier, and now it is working properly without using google() repositories, @JacoRoos , can u try without using google() in gradle?

@AghaAliAbbasKhan You sir, are a legend! How did you manage to determine this?

i figured that it dependencies are downloading from different centres based on these calls. As the dependency needed to be download was moved from jcenter so i decided to move maven above so that it uses maven for the downloading this dependency and if maven fails then use google. etc etc

@sachinsemlety
I didn't copy his code, I simply moved my jcenter reference below my maven reference as he suggested. It seems that these repository references are specific to each project. This is what my files look like now (I didn't add or remove anything, just moved the refs around):

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

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

Moving the reference worked for me as well. Thanks guys.

i faced the same issue today, it was basically that gradle was not able to find this dependency.
So in order to resolve it i changed the following things in build.gradle files. There are two build.gradle files in ionic project.
change the order of repositories in both of them, take jcenter() to the bottom and add google() to the top and issue gets resolved, build successfully.

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

allprojects {
repositories {
mavenCentral();
google();
jcenter()
}
}

THATS WORKED FOR ME!

@wuxiran We faced the same problem, using Jenkins to build the APK.
We temporarily solved this problem by injecting the "google()" at the top of the repositories in build.gradle by adding this to the Jenkins script

sh ''' awk '/repositories/{print;print "google() ";next}1' build.gradle > build.gradle.tmp && mv build.gradle.tmp build.gradle '''

Thanks for your issue! This issue is related to Cordova and Cordova plugins and not Ionic. So I close this here

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manucorporat picture manucorporat  路  3Comments

brandyscarney picture brandyscarney  路  3Comments

alexbainbridge picture alexbainbridge  路  3Comments

GeorgeAnanthSoosai picture GeorgeAnanthSoosai  路  3Comments

Nick-The-Uncharted picture Nick-The-Uncharted  路  3Comments