Search code examples
androidkotlindependency-managementgradle-kotlin-dsl

Android Kotlin DSL gradle not finding dependencies in custom repositories


I'm currently converting my build.gradle file to build.gradle.kts. The heavy lifting is done and I've created a version catalogue libs.versions.toml file to handle dependency management. However, I am having an issue whereby it seems it is not picking up the custom maven repositories as the app is failing to resolve four dependencies.

My dependencies are as follows:

        //Dependency Injection        
        implementation(libs.hilt.android)
        kapt(libs.hilt.android)
        kapt(libs.androidx.hilt.compiler)
        annotationProcessor(libs.hilt.compiler)

        //View
        implementation(libs.androidx.activity)
        implementation(libs.androidx.constraintlayout)
        implementation(libs.customtoast)
        implementation(libs.picasso.transformations)
        implementation(libs.picasso)
        implementation(libs.qrgen)
        implementation(libs.accessibility.tools) <-- not resolved
        implementation(libs.apachecommons.text)
        implementation(libs.custom.progressindicator) <-- not resolved
        implementation(libs.decocharting)
        implementation(libs.avilibrary) <-- not resolved

        //Coroutines
        implementation(libs.coroutines.android)
        implementation(libs.coroutines.core)

        //LiveData
        implementation(libs.livedata.ktx)
        kapt(libs.livedata.lifecycle.compiler)
        implementation(libs.livedata.lifecycle.extensions)

        // ViewModel
        implementation(libs.viewmodel.ktx)
        implementation(libs.viewmodel.compose)
        implementation(libs.viewmodel.savedstate)
        implementation(libs.viewmodel.lifecycleruntime.ktx)

        //Networking
        implementation(libs.retrofit)
        implementation(libs.retrofit.gson.converter)
        implementation(libs.okhttp.logging.interceptor)
        implementation(project(":devenvironmentswitcher"))
        implementation(libs.okhttp)
        implementation(libs.gson)
        implementation(libs.gson.extras)
        implementation(libs.loopj.async)

        //UI - Compose
        implementation(libs.compose.ui)
        implementation(libs.compose.ui.preview)
        implementation(libs.compose.ui.material)
        implementation(libs.material)

        //Database
        implementation(libs.room.runtime)
        implementation(libs.room.ktx)
        kapt(libs.room.compiler.kapt)

        //Analytics
        implementation(platform(libs.firebase.bom))
        implementation(libs.firebase.crashlytics)
        implementation(libs.firebase.analytics)
        implementation(libs.firebase.performance)

        //Androidx
        implementation(libs.androidx.recyclerview)
        implementation(libs.androidx.cardview)
        implementation(libs.androidx.v4legacysupport)
        implementation(libs.androidx.browser)
        implementation(libs.androidx.exif)
        implementation(libs.androidx.multidex)
        implementation(libs.androidx.appcompat)

        //Messaging
        implementation(libs.firebase.messaging)
        implementation(libs.firebase.core)
        implementation(libs.azure.notification.handler) <-- Not resolved
        implementation(libs.azure.notification.hub)

        //Play Services
        implementation(libs.playservices.auth)
        implementation(libs.playservices.gcm)
        implementation(libs.playservices.location)
        implementation(libs.playservices.maps)
        implementation(libs.playservices.vision)
        implementation(libs.playservices.licenses)

        //Encryption
        implementation(libs.spongy.castle)
        implementation(libs.scotty.aes.crypt)

        //Testing
        testImplementation(libs.test.junit)
        testImplementation(libs.test.hilt.testing)
        testImplementation(libs.test.coroutines.test)
        testImplementation(libs.test.mockk)
        kaptTest(libs.test.hilt.compiler.testing)
        androidTestImplementation(libs.test.junit.androidx)
        androidTestImplementation(libs.test.rules)
        androidTestImplementation(libs.test.junit.ktx)
        androidTestImplementation(libs.test.espresso.core)
        implementation(libs.test.arch.testing)

        //Misc
        implementation(libs.scotty.rootbeer)
        implementation(libs.joda)
        implementation(libs.device.names)
        implementation(libs.iocard)

The highlighted dependencies are added to the .toml file as follows:

custom-progressindicator = { group = "com.kaopiz", name = "kprogresshud", version.ref = "progress_hud_version"}
avilibrary = { group = "com.wang.avi", name = "library", version.ref = "wang_avi_version"}
azure-notification-handler = { group = "com.microsoft.azure", name = "azure-notifications-handler", version.ref = "microsoft_notification_handler_version"}
accessibility-tools = { group = "com.novoda", name = "accessibilitools", version.ref = "novoda_accessibility_version"}

I have handled dependency resolution managed to the project settings.gradle.kts as follows:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()

        maven (url = "https://jitpack.io")
        maven (url = "https://dl.bintray.com/microsoftazuremobile/SDK")
        maven (url =  "https://dl.bintray.com/81813780/maven")
    }
}

You can see here the custom repo urls. These are working in the old build.gradle Can anyone see what it is that I am doing wrong?

When I run the androidDependencies gradle task I get the following output:

   > Could not find com.novoda:accessibilitools:1.6.0.
     Required by:
         project :app
   > Could not find com.kaopiz:kprogresshud:1.2.0.
     Required by:
         project :app
   > Could not find com.wang.avi:library:2.1.3.
     Required by:
         project :app
   > Could not find com.microsoft.azure:azure-notifications-handler:3.5.1.
     Required by:
         project :app

Solution

  • accessibilitytools, wang's avi library and kprogresshud are very old libraries, originally hosted in jcenter but now not available anymore.

    Working with old libraries is always difficult. My suggestion is to download the source code from github and try to integrate them into your project (if the license allows it). This comes, of course, with some risks or might need adjustments in the code.

    For the Microsoft library, you can integrate the new one here: https://github.com/Azure/azure-notificationhubs-android

    Hope this helps