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. 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
  3. 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
  4. 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
  5. This comment has been removed by the author.

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

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

    ReplyDelete
  8. 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
  9. 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
  10. 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
  11. isc888 เว็บตรง แทงบอลสด, แทงบอลสเต็ป, บอลเต็ง, แทงบอลสเต็ป Live, แทงบอลเตะมุม, แทงบอลราคาพูล จากต่างประเทศ มีราคาบอลให้เลือกทั้ง ราคาบอลมาเลย์ ราคาบอลฮ่องกง ราคาบอลยุโรป นอกจากนี้ทางเว็บเราสามารถเลือกแทงบอล แบบ เต็มเวลา, 45 นาที และ 90 นาที และรูปแบบการแทงบอลอีกมากมาย.

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

    ReplyDelete
  13. 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
  14. 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
  15. With the help of cheap assignment writing services, any student can get their assignments done at a reasonable price.

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

    ReplyDelete
  17. 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
  18. "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

  19. "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

  20. 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
  21. It integrates the healing power of sound vibrations with the benefits of massage therapy, creating a deeply immersive and transformative experience for recipients.

    ReplyDelete
  22. Anma Massage has evolved over centuries and is still practiced today as both a therapeutic modality and a form of relaxation.

    ReplyDelete
  23. Discover the benefits, find top-notch spas, and learn how to choose the perfect massage for your needs massage parlour near me

    ReplyDelete
  24. When relaxing massage strokes are applied the body is stimulated to release natural endorphins such as serotonin and dopamine.

    ReplyDelete
  25. Mayan abdominal treatment can often be safely integrated with conventional fertility treatments, but it's crucial to consult with the specialists at Fullblue Fertility. They can assess your unique situation and determine whether Mayan abdominal treatment is suitable and can complement your existing treatment plan.

    ReplyDelete
  26. Nice Blog! Your ctreativity is good and content is usefull. If yopu are looking for full stack development training in noida

    ReplyDelete
  27. Whether you're looking for a From various female to male massage near me techniques to ambiance considerations, we'll cover it all, ensuring you make an informed choice for a serene experience to relieve muscle tension

    ReplyDelete
  28. Brand Liaison provides complete support in EPR Registration by managing documentation and formalities in getting EPR Certificate.
    Documents Required for EPR Registration E-Waste
    EPR Authorization
    EPR Authorization is mandatory for all Producers, Importers, Brand Owners & Manufacturers of Electronics, Plastic Packaging, Batteries & Tyres in India. Team Corpseed Will Help you with the technical consultant on the applicability of EPR rules on your business and also help you with the documentation to acquire registration/Certification from CPCB

    ReplyDelete

  29. Thank you for sharing this Blog, This is more informative and nice.

    Testing tools Training in Hyderabad

    ReplyDelete
  30. You can get rid of fatigue, headaches, body aches and tiredness with our services. We also help you achieve a radiant skin. This service is offered at Spa in Chennai.

    ReplyDelete
  31. Aromatherapy is the application of essential oils from plants for relaxation and therapeutic effects. Aromatherapy can be used in male to female massages, or even the air. Our therapists have a high level of experience and are certified. You can relax while they care for your skin.

    ReplyDelete

Post a Comment

Popular posts from this blog

AntiPattern: freezing a UI with Broadcast Receiver

NotificationListenerService and kitkat