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. +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
  21. 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

  22. 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
  23. Amazing article..!! Thank you so much for this informative post. I found some interesting points and lots of information from your blog. Thanks 메이저놀이터


    ReplyDelete
  24. I've been searching for hours on this topic and finally found your post. 슬롯사이트, I have read your post and I am very impressed. We prefer your opinion and will visit this site frequently to refer to your opinion. When would you like to visit my site?

    ReplyDelete
  25. 메이저토토사이트모음January 4, 2022 at 11:02 AM

    Your ideas inspired me very much. 메이저토토사이트모음 It's amazing. I want to learn your writing skills. In fact, I also have a website. If you are okay, please visit once and leave your opinion. Thank you.

    ReplyDelete
  26. https://gamebegin.xyz You can training alone. A pitching machine permits you to set the pace of your tennis ball. By packing a number of baseballs into the machine, you may training hitting without needing a pitcher. This digital unit is great for those who wish to training baseball by itself. Pitching equipment could be acquired at the nearby showing off products retailer.

    ReplyDelete
  27. We are a top rated MGX3991 Assessment Answers Online service here with experts specializing in a wide range of disciplines ensuring you get the assignments that score maximum grades.

    ReplyDelete
  28. This is really great work. Thank you for sharing such a useful information here in the blog. 경마

    ReplyDelete
  29. Great information, thanks for sharing it with us 릴게임

    ReplyDelete
  30. This excellent website truly has all of the information I needed about this subject and didn’t know who to ask. 토토사이트


    ReplyDelete
  31. i'm able to see which you are an clever at your showground! i am launching a website quickly, and your advice can be exceedingly beneficial for me.. thanks for all of your help and wishing you all the feint in your problem.! Tweakbit Fixmypc License Key

    ReplyDelete
  32. prevail! it may be one of the most useful blogs we've ever come across upon the situation. terrific data! Im plus an skillful in this subject matter correspondingly i can take your effort completely dexterously. thanks for the large backing. https://wishesquotz.com/brothers-day-quotes/

    ReplyDelete
  33. With the help of cheap assignment writing services, any student can get their assignments done at a reasonable price.

    ReplyDelete
  34. Excellent blog!!! I really enjoy to read your post and thanks for sharing!
    Spousal Support in Virginia
    Virginia Spousal Support

    ReplyDelete
  35. it’s very helpful thanks for your valuable information follow us
    Tableau online training in Hyderabad

    ReplyDelete
  36. Nice blog I really inspired to read this blog, Thanks for providing. Improve your website's search engine ranking and increase your online visibility with the ultimate list of top guest posting sites.

    ReplyDelete
  37. "Different types of Non-Government Organizations(NGOs) Visit types of ngo in india.com!. in India - Learn about the various types of NGOs in India with this informative blog, which explores the different categories of non-government organizations."

    ReplyDelete

  38. "We are OSHA NRTL certification consultants and make certification easy for American and Canadian market. Get NRTL Certificate for USA / America now. Click here NRTL certification.com to know all about how to get an NRTL certification for USA and Canada."

    ReplyDelete

  39. Want to enter the Canadian market for telecommunication products? Click here Industry Canada Certification.com to know - how to obtain Industry Canada Certification easily? Get your IC Certification mark for Import- Export for Canada now from best consultants.

    ReplyDelete

Post a Comment

Popular posts from this blog

AntiPattern: freezing a UI with Broadcast Receiver

NotificationListenerService and kitkat