Error resolving dependencies for gradle-bintray-plugin on Cordova

I’m trying to build an Android project using Cordova, but I’m getting the following error:

Could not resolve all artifacts for configuration ':CordovaLib:classpath'. Could not find com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3.

I’ve checked the download locations mentioned in the error and it seems that the plugin is not available. I’ve also tried --stacktrace, but I’m not getting any more relevant information. Does anyone know how to resolve this issue or have any suggestions on how to proceed?

I have managed to resolve the above issue, however, I am now facing a new error related to the Bintray library, which requires the http-builder.0.7.2 dependency. I tried applying the same solution as before, adding the https://nexus.web.cern.ch/nexus/content/repositories/public/ repository in the platforms/android/app/build.gradle file. I also added the following line in the dependencies: classpath 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.2'.

Additionally, I tried including the repository in the platforms/android/build.gradle file, but doing so, it no longer recognized the Bintray dependency. Now I am not sure how to make both dependencies work properly. I would appreciate any guidance you could provide.


NOTA!! La solucion para lo de bintray fue agregar los siguientes repositorios en el platforms/android/build.gradle:

buildscript {
    repositories {
        google()
        mavenCentral() 
        maven { url 'https://jitpack.io' }
        maven { url 'https://plugins.gradle.org/m2/' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' 
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
        maven { url 'https://plugins.gradle.org/m2/' }
    }
}

Can you please edit your posts and translate them to English, which is the language of this community?

1 Like

Please also translate the remaining sentence.

Besides that, some notes first:

  • maven { url 'https://plugins.gradle.org/m2/' } can be replaced by gradlePluginPortal().
  • I strongly recommend not to use JitPack if you can anyhow avoid using it, and if you really need it, at least use a content repository filter to define what exactly to take from there. It is broken-by-design as normal repository, unreliable, buggy, and slow.
  • You should not use a buildscript { ... } block to add plugins to the classpath, but use the plugins { ... } block instead to apply plugins, or to add them to the classpath.
  • You should not depend on gradlePluginPortal() in your normal repositories unless you develop an actual Gradle plugin where you need other plugins as production dependencies
  • Using allprojects { ... } or any other means of cross-project configuration is highly discouraged. It immediately introduces project coupling and works-against or disables some more sophisticated Gradle features and optimizations. Instead use convention plugins to centralize build logic, for example in buildSrc or an included build, for example implemented as precompiled script plugin.
  • More a personal recommendation, I strongly suggest switching to Kotlin DSL. By now it is the default DSL, you immediately get type-safe build scripts, actually helpful error messages if you mess up the syntax, and amazingly better IDE support if you use a good IDE like IntelliJ IDEA or Android Studio.

Regarding resolving com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3, it is available on Gradle plugin portal: https://mvnrepository.com/artifact/com.jfrog.bintray.gradle/gradle-bintray-plugin/1.7.3, so if you use the plugins { ... } block it will work with the default plugin repositories, or with non-default as long as you include the plugin portal. Its transitive org.codehaus.groovy.modules.http-builder:http-builder:0.7.2 dependency though seems only being available on some exotic repositiories: https://mvnrepository.com/artifact/org.codehaus.groovy.modules.http-builder/http-builder/0.7.2 so you need to add one of those.

Or don’t use the plugin at all?
Seems to be quite unmaintained.

For me, I’m updating a legacy application

using Cordova CLI v9
cordova-android v8.1.0
Ionic v4.11.0
JDK 8
Gradle 6.9 installed (though based on gradle-wrapper.properties 4.10.3 is being used

In
\platforms\android\CordovaLib\build.gradle

add:

    repositories {
        ...
        mavenCentral()
        maven { url 'https://plugins.gradle.org/m2/' }
        maven { url 'https://groovy.jfrog.io/artifactory/libs-release/' }
        ...
    }

eg:

buildscript {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://plugins.gradle.org/m2/' }
        maven { url 'https://groovy.jfrog.io/artifactory/libs-release/' }
        jcenter()
    }

    dependencies {
        // The gradle plugin and the maven plugin have to be updated after each version of Android
        // studio comes out
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://plugins.gradle.org/m2/' }
        maven { url 'https://groovy.jfrog.io/artifactory/libs-release/' }
        jcenter()
    }
}

https://plugins.gradle.org/m2/ is needed for com.jfrog.bintray.gradle
https://groovy.jfrog.io/artifactory/libs-release/ is needed for org.codehaus.groovy.modules.http-builder

Is that a try to answer something or do you have some problem?
If the latter, is it related to this thread?
Your snippets are also full of discouraged bad practices or time-waste.

For example you can use gradlePluginPortal() instead of manual URL.
Using jcenter() is pointless, by now it is just a redirect to mavenCentral() and thus wasting time for any non-found lib that is searched in mavenCentral() twice.
Using buildscript { ... } is not a good idea for plugins, the recommended way is to define plugin repositories in your settings script and using the plugins { ... } block to apply the plugins or bring them onto the classpath.
allproject { ... } or any other means of doing cross-project configuration or even cross-project model information gathering is highly discouraged as it immediately introduces project coupling which works against more sophisticated Gradle features and optimizations.

1 Like

Hi Bjorn!

Sorry for the lack of context, I was actually trying to get a legacy Ionic project to build again, which is using Cordova-Android v8.1.0 from back in 2020-ish
and the error is in Gradle file of cordova-android during the build process

I was faced with the same errors that the OP, Isaac faced (I believe he is also using cordova-android)
Additionally, your input about the http-builder dependency helped me a lot in getting it fixed, I did indeed face error with http-builder.

The fixed fork here: GitHub - NicksonYap/cordova-android: Apache Cordova Android

The “bad code” is from the developers of cordova-android, I merely just added the maven repositories and to reduce unnecessary changes to getting it to work, hence remained the reference to jCenter().
Any one who wants to fix their copy of old cordova-android can simply remove it as well

cordova-android developers are no longer making any changes to this version, I really appreciate your inputs such as the redundant allprojects {...}, and will take notice of them in the future!

It’s Björn or Bjoern, not Bjorn. :wink:

I really appreciate your inputs such as the redundant allprojects {...}

Redundant is the wrong word.
allprojects { ... } does do something unless you only have one project anyway, then it is indeed just redundant.
In any other case it is highly discouraged bad practice and should be replaced by something else, in that case dependencyResolutionManagement { repositories { ... } } in the settings script, in other cases by convention plugins.

1 Like

I love how you’re so precise!

Noted on the above Bjoern,
learned quite a few things today!

1 Like