Search code examples
android-gradle-plugingradle-kotlin-dsl

dependency url keeps getting appened to the end of our nexus respository


Migrated to Kotlin .kts and now I'm getting some build issues.

These are some of the errors:

> Could not resolve all files for configuration ':app:stagingNewDesignDebugRuntimeClasspath'.
   > Could not resolve com.pierfrancescosoffritti.androidyoutubeplayer:core:10.0.5.
     Required by:
         project :app
      > Could not resolve com.pierfrancescosoffritti.androidyoutubeplayer:core:10.0.5.
         > Could not get resource 'https://nexus.central.tech/repository/nexus-releases/com/pierfrancescosoffritti/androidyoutubeplayer/core/10.0.5/core-10.0.5.pom'.
            > Could not HEAD 'https://nexus.central.tech/repository/nexus-releases/com/pierfrancescosoffritti/androidyoutubeplayer/core/10.0.5/core-10.0.5.pom'. Received status code 401 from server: Unauthorized
      > Could not resolve com.pierfrancescosoffritti.androidyoutubeplayer:core:10.0.5.
         > Could not get resource 'https://s3.amazonaws.com/salesforcesos.com/android/maven/release/com/pierfrancescosoffritti/androidyoutubeplayer/core/10.0.5/core-10.0.5.pom'.

What I don't understand is that the dependency being appended to our Nexus server.

Could not resolve com.pierfrancescosoffritti.androidyoutubeplayer:core:10.0.5.
         > Could not get resource 'https://nexus.central.tech/repository/nexus-releases/com/pierfrancescosoffritti/androidyoutubeplayer/core/10.0.5/core-10.0.5.pom

Our Nexus repository is https://nexus.central.tech/repository/nexus-releases But /com/pierfrancescosoffritti/androidyoutubeplayer/core/10.0.5/core-10.0.5.pom keeps getting appended to it. And that is why it can't find the full path and the build will fail.

androidyoutubeplayer doesn't come from our Nexus so I don't understand why it's trying to get it from there.

// build.gradle.kts

repositories {
      google()
      mavenCentral()
      maven {
          url = uri(properties["nexusRepositoryUrl"].toString())
  
          credentials {
              username = properties["nexusRepositoryUsername"].toString()
              username = properties["nexusRepositoryPassword"].toString()
          }
      }
        
      maven { url = uri("https://www.jitpack.io") }
      maven { url = uri("https://s3.amazonaws.com/salesforcesos.com/android/maven/release") }
      maven { url = uri("https://dl.bintray.com/objectbox/objectbox") }
      maven { url = uri("https://sdk.uxcam.com/android/") }
}

UPDATE -- after correcting the username/password

Could not determine the dependencies of task ':app:compileUatDebugKotlin'.
> Could not resolve all files for configuration ':app:stagingNewDesignDebugRuntimeClasspath'.
   > Could not resolve com.pierfrancescosoffritti.androidyoutubeplayer:core:10.0.5.
     Required by:
         project :app
      > Skipped due to earlier error
      > Could not resolve com.pierfrancescosoffritti.androidyoutubeplayer:core:10.0.5.
         > Could not get resource 'https://s3.amazonaws.com/salesforcesos.com/android/maven/release/com/pierfrancescosoffritti/androidyoutubeplayer/core/10.0.5/core-10.0.5.pom'.
            > Could not HEAD 'https://s3.amazonaws.com/salesforcesos.com/android/maven/release/com/pierfrancescosoffritti/androidyoutubeplayer/core/10.0.5/core-10.0.5.pom'. Received status code 403 from server: Forbidden

After looking at the git repo for androidyoutubeplayer. It should fetch that dependency from mavenCentral(). So Not sure why its looking at the above.

=== UPDATE 2 === jcenter() was removed originally, but I have put it back as we have some libraries that are old from there that haven't found their way to mavenCentral(). That was why some of the dependencies could not be found. So it was continue to search the other repositories.

This is build.gradle.kts

repositories {
    google()
    jcenter()
    mavenCentral()
    maven {
        url = uri(properties["nexusRepositoryUrl"].toString())

        credentials {
            username = properties["nexusRepositoryUsername"].toString()
            password = properties["nexusRepositoryPassword"].toString()

            /* TODO: Remove after debugging */
            println("USERNAME: $username")
            println("PASSWORD: $password")
            println("URL: $url")
        }
    }

    maven { url = uri("https://sdk.uxcam.com/android/") }
    maven { url = uri("https://www.jitpack.io") }
    maven { url = uri("https://s3.amazonaws.com/salesforcesos.com/android/maven/release") }
    maven { url = uri("https://dl.bintray.com/objectbox/objectbox") }
}

And this is the build.gradle (working ok)

repositories {
    google()
    jcenter()
    mavenCentral()
    maven {
        url nexusRepositoryUrl

        credentials {
            username nexusRepositoryUsername
            password nexusRepositoryPassword
        }
    }
    maven { url 'https://sdk.uxcam.com/android/'}
    maven { url "https://www.jitpack.io" }
    maven { url 'https://s3.amazonaws.com/salesforcesos.com/android/maven/release' }
    maven { url "https://dl.bintray.com/objectbox/objectbox" }
}

The errors are different now. This is what I get when building:

.gradle/caches/transforms-2/files-2.1/8fc5090e854d3eadc13743a6b4942213/jetified-kotlin-stdlib-1.6.0.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.2.


.gradle/caches/transforms-2/files-2.1/bdaa895e8cd4dd25cc3b271fb1f2fc8e/jetified-kotlin-stdlib-jdk7-1.6.0.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.2.

.gradle/caches/transforms-2/files-2.1/cebf6956c831e2c0ba58bc90c4d45ce7/jetified-kotlin-stdlib-common-1.6.0.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.2.

.gradle/caches/transforms-2/files-2.1/e0c09723c14595670dad4b40acbe2360/jetified-core-11.0.1-api.jar!/META-INF/core_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.2.

.gradle/caches/transforms-2/files-2.1/ec9cde959f0fd7b7d9fe2427414ce447/jetified-kotlin-stdlib-jdk8-1.6.0.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.2.

This is my project level build.gradle.kts

buildscript {
    val kotlin_version = "1.4.32"
    val navigationVersion = "2.3.5"
    val objectboxVersion = "2.9.1"
    val jacocoVersion = "0.8.5"
    val sonarVersion = "3.0"
    val newRelicVersion = "5.28.1"

    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath("com.android.tools.build:gradle:4.2.2")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:")
        classpath("org.jetbrains.kotlin:kotlin-noarg:$kotlin_version")
        classpath("org.jacoco:org.jacoco.core:$jacocoVersion")
        classpath("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:$sonarVersion")
        classpath("androidx.navigation:navigation-safe-args-gradle-plugin:$navigationVersion")
        classpath("com.google.gms:google-services:4.3.8")
        classpath("com.google.firebase:perf-plugin:1.3.4")
        classpath("com.google.firebase:firebase-appdistribution-gradle:2.0.1")
        classpath("com.google.firebase:firebase-crashlytics-gradle:2.4.1")
        classpath("io.objectbox:objectbox-gradle-plugin:$objectboxVersion")
        classpath("com.newrelic.agent.android:agent-gradle-plugin:$newRelicVersion")
        classpath("com.akaita.android:easylauncher:1.3.1")

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

What I don't understand the build.gradle before migration works fine and all the versions of kotlin and dependencies are the same. As I have it on another branch.

When running the following command ./gradlew assembleUat --info

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://s3.amazonaws.com/salesforcesos.com/android/maven/release/com/google/firebase/firebase-messaging/maven-metadata.xml)]
Failed to get resource: GET. [HTTP HTTP/1.1 502 Bad Gateway: https://dl.bintray.com/objectbox/objectbox/com/google/firebase/firebase-messaging/maven-metadata.xml)]
Failed to get resource: GET. [HTTP HTTP/1.1 502 Bad Gateway: https://dl.bintray.com/objectbox/objectbox/com/google/firebase/firebase-messaging/maven-metadata.xml)]
Failed to get resource: GET. [HTTP HTTP/1.1 502 Bad Gateway: https://dl.bintray.com/objectbox/objectbox/com/google/firebase/firebase-messaging/maven-metadata.xml)]
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://s3.amazonaws.com/salesforcesos.com/android/maven/release/com/google/android/gms/play-services-location/maven-metadata.xml)]
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://s3.amazonaws.com/salesforcesos.com/android/maven/release/com/google/android/gms/play-services-ads-identifier/maven-metadata.xml)]
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://s3.amazonaws.com/salesforcesos.com/android/maven/release/com/google/android/gms/play-services-base/maven-metadata.xml)]
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://s3.amazonaws.com/salesforcesos.com/android/maven/release/com/akamai/android/aka-common/maven-metadata.xml)]

Solution

  • The solution was based on @aSemy comment. Which was to include only the dependencies that are needed for those repositories.

      maven {
            url = uri("https://s3.amazonaws.com/salesforcesos.com/android/maven/release")
            content {
                includeGroup("com.salesforce.service")
                includeGroup("com.salesforce.android")
            }
        }
    
        maven {
            url = uri("https://dl.bintray.com/objectbox/objectbox")
    
            content {
                includeGroup("io.objectbox")
            }
        }