Gradle Dependency Management w/Kotlin and buildSrc for build.gradle Autocomplete in Android Studio

Ғылым және технология

Did you know you can write Kotlin in a module named buildSrc to manage your dependencies in your Gradle files?
How? When you run Gradle, it checks for the existence of a directory called buildSrc. Gradle then automatically compiles this code and puts it in the classpath of your build script. You don’t need to provide any further instruction.
It may not seem like it’s that big of a deal, but managing Gradle dependencies is a pain, and getting to use Kotlin and having autocomplete in Android Studios is a game changer.

Пікірлер: 8

  • @GakisStylianos
    @GakisStylianos3 жыл бұрын

    What's your opinion about Gradle's version catalogue feature coming with Gradle 7.0? Sounds like a better alternative to this, as I've heard the buildSrc approach doesn't work super well with build speeds

  • @rcgonzalezf

    @rcgonzalezf

    2 жыл бұрын

    I agree, it will be interesting to find out the answer to this question ;)

  • @kumarkartikeya5240
    @kumarkartikeya52402 жыл бұрын

    Is it possible to add a local module dependency inside buildSrc module.

  • @Chaseosa
    @Chaseosa3 жыл бұрын

    Did you copy this video exactly from Mighty Programmer?

  • @muhammadsarimmehdi
    @muhammadsarimmehdi Жыл бұрын

    Execution failed for task ':buildSrc:validatePlugins'. > Could not resolve all files for configuration ':buildSrc:compileClasspath'. > Cannot resolve external dependency org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.31 because no repositories are defined. Required by: project :buildSrc > Cannot resolve external dependency org.jetbrains.kotlin:kotlin-reflect:1.5.31 because no repositories are defined. Required by: project :buildSrc

  • @user-wo8df9dr2b

    @user-wo8df9dr2b

    7 ай бұрын

    I solved adding this to build.gradle.kts(:buildSrc) repositories { mavenCentral() google() }

  • @sayanbanerjee8083

    @sayanbanerjee8083

    7 ай бұрын

    Just came across this video and got the same error. I'm adding the solution here. If anyone is stuck like us, they might get some help from this comment: SOLUTION: You need to add "repositories" under "build.gradle.kts" file, like the following: repositories { google() mavenCentral() } Now sync and run! It'll work.

Келесі