Android build

Hi,

I tried to do this command line : ionic cordova build android and have this error message :slight_smile:
FAILURE: Build failed with an exception.

  • What went wrong:
    Could not resolve all files for configuration ‘:app:debugCompileClasspath’.

Could not find support-v4.jar (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.jar

  • 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 4s
26 actionable tasks: 1 executed, 25 up-to-date
(node:34260) UnhandledPromiseRejectionWarning: Error: /Users/cpuser/desktop/vivendiSafe/myApp/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

  • What went wrong:
    Could not resolve all files for configuration ‘:app:debugCompileClasspath’.

Could not find support-v4.jar (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.jar

  • 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 4s
at ChildProcess.whenDone (/Users/cpuser/desktop/vivendiSafe/myApp/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:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:34260) 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:34260) [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.

Somebody can help me ?

Thx

Me too :cold_sweat::scream:

What is your ionic info output?

I have fixed it:

  1. Adding this line in platforms/android/build.gradle
    allprojects {
    repositories {
    mavenCentral();
    maven { url ‘https://maven.google.com’ } //Added this line
    jcenter()
    }
    }

  2. And adding this plugin:

    ionic cordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=25.+

I got this same error. In my case I previously had to mess with resolving multiple plugins needing multiple versions of support-v4. As @goinnn noted, one option to fix that is the cordova-android-support-gradle-release plugin, to pin to a specific version. I personally added a build-extras.gradle (with a hook) to do something similar (below). For some reason I was completely fine doing 26+ for the version for quite a while. Now that breaks for me, but forcing it to 26.0+ seems to work. I’m guessing the 26.1.0 release (which is the latest that fits 26.+) isn’t published quite the same as 26.0.2, and thus can’t be found.

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:26+'
    }
}

In platforms/android/build.gradle put jcenter() after maven:

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

But it’s just a workaround, which must be done againe each time build.gradle is created.
Is there a proper solution?

Hi, i suddenly get these error, it was building fine this morning.

Could not resolve all files for configuration ‘:CordovaLib:classpath’.
Could not find manifest-merger.jar (com.android.tools.build:manifest-merger:26.0.0).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/manifest-merger/26.0.0/manifest-merger-26.0.0.jar
Could not find ddmlib.jar (com.android.tools.ddms:ddmlib:26.0.0).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/ddms/ddmlib/26.0.0/ddmlib-26.0.0.jar
Could not find dvlib.jar (com.android.tools:dvlib:26.0.0).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/dvlib/26.0.0/dvlib-26.0.0.jar
Could not find common.jar (com.android.tools:common:26.0.0).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/common/26.0.0/common-26.0.0.jar

I tried moving jcenter() position like what others suggest, but wont works.

Fixed!
See comment#103