How to centralize the support libraries dependencies in gradle

Working with multi-modules project, it is very useful to centralize the dependencies, especially the support libraries.

A very good way is to separate gradle build files, defining something like:
root
  --gradleScript
  ----dependencies.gradle
  --module1
  ----build.gradle
  --build.gradle
In gradleScript/dependecies.gradle:

ext {
    //Version
    supportLibrary = '22.2.1'

    //Support Libraries dependencies
    supportDependencies = [
            design           :    "com.android.support:design:${supportLibrary}",
            recyclerView     :    "com.android.support:recyclerview-v7:${supportLibrary}",
            cardView         :    "com.android.support:cardview-v7:${supportLibrary}",
            appCompat        :    "com.android.support:appcompat-v7:${supportLibrary}",
            supportAnnotation:    "com.android.support:support-annotations:${supportLibrary}",
    ]
}
In the top level file build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
    }
}

// Load dependencies
apply from: 'gradleScript/dependencies.gradle'
In the module1/build.gradle:

// Module build file

dependencies {
    //......
    compile supportDependencies.appCompat
    compile supportDependencies.design
}
Here you can find the full gist.

Thanks to Fernando Cejas and this blog.

Comments

  1. Very Nice Blog, You are spreading very good information among us… Yes Web Hosting plays very important role in business world. And it is important to have the best hosting services.
    Germany VPS Hosting

    ReplyDelete
  2. This Article is Worth of sharing. The information is helpful for sure! Keep going like this!
    Germany VPS Hosting

    ReplyDelete
  3. Am really impressed about this blog because this blog is very easy to learn and understand clearly.This blog is very useful for the college students and researchers to take a good notes in good manner,I gained many unknown information.
    Data Science Training In Chennai

    Data Science Online Training In Chennai

    Data Science Training In Bangalore

    Data Science Training In Hyderabad

    Data Science Training In Coimbatore

    Data Science Training

    Data Science Online Training

    ReplyDelete
  4. Thanks for provide great informatics and looking beautiful blog, really nice required information & the things i never imagined and i would request, wright more blog and blog post like that for us. Thanks you
    DevOps Training in Chennai

    DevOps Online Training in Chennai

    DevOps Training in Bangalore

    DevOps Training in Hyderabad

    DevOps Training in Coimbatore

    DevOps Training

    DevOps Online Training

    ReplyDelete
  5. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
    best machine learning course online
    learn machine learning online
    Machine Learning Online training hyderabad

    ReplyDelete
  6. Stay Home And Be safe Carona effect Nice to see your blog keep updating offers & coupons Clovia Coupons and Offers- Find the latest Filpkart, Nykaa, nnnow, paytmall, Clovia Coupons and Best Offers for Men & women online shopping at Tracedeals.
    Amazon offers
    Clovia offers
    Flipkart offers
    Nykaa offers
    Nnnow offers
    Paytmmall offers
    oppo Mobile offers
    Samsung Mobile Phone
    Flipkart Coupons
    Flipkart sale
    Bookmyshow Coupons

    ReplyDelete
  7. Thank you so much for sharing your brilliant thoughts with us. Visit Ogen Infosystem for creative Website Designing and SEO Services in Delhi, India.
    Website Designing Company in Delhi

    ReplyDelete
  8. I really appreciate this post and I like this very much. I am waiting for new post here and Please keep it up in future.

    CloudBox99 offers you with the best Web hosting services in Hyderabad and facilitates enterprises to transform digitally. We keep you covered in terms of all your IT requirements with unmatched expertise and deep domain knowledge

    ReplyDelete
  9. Looking for Homework Help In The USA? I recommend that you should try our academic writing services which you will never regret trying, we offer writing services under all niches and streams within your budget.
    Read More Blog : https://bit.ly/3wvY0n0

    ReplyDelete
  10. Nice tips... Much obliged for sharing this stunning and educative blog entry! That will be useful to anyone at all time. It shows how well you understand this subject. Thanks for sharing.Our Java Programming Training In Virginia for data science and Java Developers helps all developers to become better programmers.

    ReplyDelete
  11. Assignment writing is a very challenging and time taking task when you are in colleges or universities. This is why numerous candidates are looking for the Assignment Help Online services. If you are also thinking to contact the best assignment help company, call us today.

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. This comment has been removed by the author.

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. As you are sharing the article about Android Development & you are introducing us Working with multi-modules project, it is very useful to centralize the dependencies, especially the support libraries. Yes! this blog is absolutely amazing!
    If you are looking for VPS Server & want to take full information about it, you can choose USA VPS Hosting . Here you get reliable VPS Server Hosting in the cheapest price. Don't worry about the security.

    ReplyDelete
  16. this blog is very amazing and informative i am very thankful to you share me How to centralize the support libraries dependencies in gradle ,Working with multi-modules project, it is very useful to centralize the dependencies, especially the support libraries. if you want to know about server hosting or interested in best USA VPS Hosting you can ask us for more details and services.

    ReplyDelete
  17. Amazing blog! I am feeling grateful to read this. You gave a nice information for us. Yes Web Hosting plays very important role in business world. If you want to know about Server hosting ,I can help you USA VPS hosting Join and grow your business. please updating more stuff content...keep up!!

    ReplyDelete
  18. isc888 เว็บตรง แทงบอลสด, แทงบอลสเต็ป, บอลเต็ง, แทงบอลสเต็ป Live, แทงบอลเตะมุม, แทงบอลราคาพูล จากต่างประเทศ มีราคาบอลให้เลือกทั้ง ราคาบอลมาเลย์ ราคาบอลฮ่องกง ราคาบอลยุโรป นอกจากนี้ทางเว็บเราสามารถเลือกแทงบอล แบบ เต็มเวลา, 45 นาที และ 90 นาที และรูปแบบการแทงบอลอีกมากมาย.

    ReplyDelete
  19. ngobrol games Setiap layer yang bisa ditumpuk hingga delapan kali akan menambah 60 poin Physical Damage.

    ReplyDelete
  20. Very nice post. I definitely appreciate this website. Stick with it! 토토

    ReplyDelete
  21. +96893560417 Howdy honorable man, I'm Muscat escort. I'm a head specialist co-op. Escort Muscat I give Understudies, College understudies, Incline models, and Single young ladies Oman Escort +96893560417
    Escort in Oman
    Muscat escort
    Escort Muscat
    Escort in Muscat

    ReplyDelete
  22. I am a regular reader of your blog and I find it really informative tnx for make a blog on How to centralize the support libraries dependencies in gradle ,Working with multi-modules project, it is very useful to centralize the dependencies, especially the support libraries. If you want to know about server hosting or interested in best Italy VPS Hosting you can ask us for more details and services.

    ReplyDelete
  23. Nepal Tour Packages Wonderful post! I am getting the wonderful ideas to explore top popular tourist attractions of Nepal. Travelers can learn important tips to get the best deals for Nepal tourism packages. This blog is very interesting for me. I am very happy for this amazing blog.

    ReplyDelete

  24. Nice to see this BLOG..keep updating More infromation Digital Lync offers one of the best Full Stack training in Hyderabad with a comprehensive course curriculum with Continuous Integration, Delivery, and Testing. Elevate your practical knowledge with quizzes, assignments, Competitions, and Hackathons to give a boost to your confidence with our hands-on Full Stack Training.
    DevOps Training Institute
    Python Training Institute
    AWS Training Institute
    Online Full Stack Developer Course Hyderabad
    Python Course Hyderabad
    Online AWS Training Course Hyderabad
    devops training in hyderabad
    angular training in hyderabad

    ReplyDelete

Post a Comment

Popular posts from this blog

Snippet: align a TextView around an image

NotificationListenerService and kitkat