Gradle for Beginners (Build Types, Product Flavors, Build Variants, Source Sets)

Sdílet
Vložit
  • čas přidán 27. 06. 2024
  • This video covers the core concepts of Android Gradle. That includes different build types (debug, release, etc.), product flavors and their use, build variants and how to make use of different source sets.
    Get the multi-module course here:
    elopage.com/s/philipplackner/...
    💻 Let me personally review your code and provide individual feedback, so it won't backfire and cost you a fortune in future:
    elopage.com/s/philipplackner/...
    Subscribe to my FREE newsletter for regular Android, Kotlin & Architecture advice!
    pl-coding.com/newsletter
    Join this channel to get access to perks:
    / @philipplackner
    Join my Discord server:
    / discord
    Regular programming advice on my Instagram page: / _philipplackner_
    Checkout my GitHub: github.com/philipplackner
    You like my free content? Here you can buy me a coffee:
    www.buymeacoffee.com/philippl...
    00:00 - What is Gradle?
    03:18 - Gradle Groovy vs. Gradle Kotlin DSL
    05:07 - The Gradle wrapper
    08:38 - Build types
    12:42 - Product flavors
    19:22 - Source sets

Komentáře • 125

  • @HiImMatthewN
    @HiImMatthewN Před 2 lety +14

    You sir is a gift from heaven for us Intermediate developers.

  • @disgruntled_llama
    @disgruntled_llama Před měsícem

    Why is it that ever time I go searching for an explanation of something in Android development I always seem to end up on this channel? Thanks for all of this information, Philipp! Danke Schoen!

  • @mikec4220
    @mikec4220 Před 2 lety +13

    Hoooray! Finally ! This is soo important to learn as early as possible in your dev career and many of us fail to do so! Thanks a lot Philipp

    • @Alchemist10241
      @Alchemist10241 Před rokem +1

      you're right, I've postponed learning Gradle till this video and I've suffered the consequences

  • @dariusfathi5520
    @dariusfathi5520 Před 2 lety +2

    After years of android development, finally I'm going to understand product flavors!
    Great work
    Thanks

  • @trendystatuses161
    @trendystatuses161 Před 2 lety +15

    Just what I needed, thank you

  • @shabari13
    @shabari13 Před 10 měsíci

    Thank you for doing this..For a Gradle beginner, this is such a good start

  • @sujit_ghimire
    @sujit_ghimire Před 2 lety

    Thanks Philipp for this video. You're the best.

  • @rowenarrow
    @rowenarrow Před 2 lety

    Fantastic video. I learned a lot on something I have wanted to learn about. Got some good notes from this and I am looking forward to watching more of your content.

  • @kushiskinng
    @kushiskinng Před 2 lety

    I m really glad I follow this channel.. Thanks Philip! Your content is really helpful

  • @amirhosseinparhizgar4528

    Nice one! waiting for next video on gradle. thank you Philipp

  • @rajeevkumargupta532
    @rajeevkumargupta532 Před 2 lety

    Content and knowledge, up to the mark as always ❣️

  • @pandukaful
    @pandukaful Před 2 lety

    Thank you for creating this video, it is so helpful mate.

  • @dreablin
    @dreablin Před 2 lety

    Thanks, I faced with Flavors just 2 weeks ago on a new job :)
    It may be not 100% clear from this video, but you can use different res folders as well.
    Waiting for the next part!

  • @augustocera574
    @augustocera574 Před 2 lety

    Thank you for this video Philipp!

  • @elfarouk3306
    @elfarouk3306 Před 2 lety

    I can't wait for the next video ... *You are the best*

  • @devenderchaturvedi9903
    @devenderchaturvedi9903 Před 2 lety +19

    Best Gradle video ever. I'm desperately waiting for the next part in this series. Also, If we don't want to have 2 apks for free and paid features, instead we want to have it in one apk, and unlock paid feature modules on subscription basis. How to manage this use case? Please make a video on this. There's literally no video on it.

    • @stephensiapno7361
      @stephensiapno7361 Před 2 lety +5

      If that is your usecase, then you don't need to create a buildFlavor. You just need to create a different module to separate the concern for free and paid features.

    • @devenderchaturvedi9903
      @devenderchaturvedi9903 Před 2 lety

      @@stephensiapno7361 Thanks. Sure I'll try the multi-modular approach.

    • @haykmkrtchyan7093
      @haykmkrtchyan7093 Před 2 lety

      @@devenderchaturvedi9903 If it's one apk and it's in app subscription, just use the billing library with multi module I guess

  • @adamjacob5482
    @adamjacob5482 Před 2 lety

    Thanks mate, really good content and very helpful as always

  • @TheChustek
    @TheChustek Před rokem

    OP explanation Philipp, Good Job!

  • @adcmjbe
    @adcmjbe Před rokem +10

    You do have a way of making complex concepts "almost" simple ;)
    Thanks for another great video ...

  • @milon27
    @milon27 Před 2 lety

    i was waiting for so long

  • @rileyfarro6801
    @rileyfarro6801 Před 2 lety

    I really needed this, thank you!

  • @kushal7966
    @kushal7966 Před rokem

    Thanks for the video .. its helpful at right time ....

  • @kapileshrajput456
    @kapileshrajput456 Před 2 lety

    Really great explanation, thank you.

  • @omidphoenix4883
    @omidphoenix4883 Před 2 lety

    Thanks brother! good job! 🙏

  • @elangovankr110
    @elangovankr110 Před 2 lety

    Very useful video. Expecting more like this.

  • @maverick7695
    @maverick7695 Před 2 lety

    Always amazing philipp ,, keep up the good tutorials ❤❤

  • @smelkova5826
    @smelkova5826 Před rokem

    Thank you so much for this helpful video

  • @ashwinpatidar2878
    @ashwinpatidar2878 Před 2 lety

    Superb Explanation

  • @jjhoninatan55sabadi
    @jjhoninatan55sabadi Před 2 lety

    I wish i could like your video 100 times!

  • @chrisfelix9065
    @chrisfelix9065 Před 2 lety

    God bless you for treating this topic

  • @luke7551
    @luke7551 Před 2 lety

    Gradle is most confusing thing when I start to learn Android development. Thank you so much for such useful content. I hope you will making tutorials on working with rich text formatting on typing.

  • @alihosseinnezhad2957
    @alihosseinnezhad2957 Před 2 lety

    Interesting. Thanks Philip 😊.

  • @axw-ei3fn
    @axw-ei3fn Před rokem

    This videos tutorials is very helpful to me .

  • @niroshanrathnayake7002

    Really helpful. Good one. Thank You

  • @adeltarek9114
    @adeltarek9114 Před 2 lety

    I didn't watched it yet But of course I LIKED IT
    Because You decided to talk about something has a lack of resources, I appreciate it ❤️

  • @anandbehera1969
    @anandbehera1969 Před 2 lety

    Helpful Content.. Thanks

  • @muhammadirvan8655
    @muhammadirvan8655 Před 2 lety

    Great explanation for beginner, its complicated sometime for new comers who learn Android Apps to know what is Gradle actually. thank you Philipp

  • @alphacoder3822
    @alphacoder3822 Před 2 lety

    2 german dudes making amazing android content.
    1. Philip
    2. Florin walther from coding in flow

  • @jeckonly5853
    @jeckonly5853 Před 2 lety

    So thanks!!!You help me a lot!!
    😲

  • @khaled.noordin
    @khaled.noordin Před 2 lety

    Great topic. Thanks a lot

  • @milon27
    @milon27 Před 2 lety

    love you man

  • @samsammaniamantap
    @samsammaniamantap Před 2 lety

    Thanks Phil, sekarang saya lebih mengerti tentang Flavors

  • @unaisulhadi9102
    @unaisulhadi9102 Před 2 lety

    Amazing video!
    Please do a video about Kotlin DSL also.

  • @mustafaammar551
    @mustafaammar551 Před 2 lety

    Very cool video thank you BRO 🔥🔥🔥 👍👍👍

  • @santoshs490
    @santoshs490 Před 2 lety

    Great video...!! Thanks

  • @amineayachi335
    @amineayachi335 Před 2 lety

    what a great video thanks

  • @TiagoDvl
    @TiagoDvl Před 2 lety

    As always: super helpful! I would love to have more insights on how do you know what folder to choose from that long list when you type "test" or "testDebug".

    • @PhilippLackner
      @PhilippLackner  Před 2 lety +1

      It's really just about deciding which build variant you have specific behavior or specific resources for and then picking the folder for that build variant. Usually, you either select the /java folder or /res folder depending on what differs for that variant. If you write tests for it, you of course choose the test or androidTest source set depending on the type of tests.

  • @cashat
    @cashat Před rokem

    Thank you for this awesome video , Wil you organize it with the second video in a playlist?! I couldn't find the other one

  • @jamief123
    @jamief123 Před 2 lety

    Thanks for this. Gradle is a bit of a mystery to me and I never really understood what it was doing.

  • @timurabdyraev4447
    @timurabdyraev4447 Před 2 lety

    Beg you:
    Make a detailed video about Gradle version catalogs. Really need it now

  • @Sepphirex
    @Sepphirex Před 2 lety

    Thank you so much!

  • @studiomacbookpro159
    @studiomacbookpro159 Před 2 lety

    very nice topic

  • @haykmkrtchyan7093
    @haykmkrtchyan7093 Před 2 lety

    Great tutorial. Just one more question. If we have some flavours, do we use source sets to implement the flavour specific functionality? Like one source set for the free app and one source set for the paid one?

  • @tiamabderezai5374
    @tiamabderezai5374 Před rokem

    Philipp! Make a video explaining build variants and flavors (release, debug, etc) please

  • @CivoMT
    @CivoMT Před 2 lety +9

    Great and easy to understand as always! Philip could you make a video with explanation of MVI architecture? Or Even some application with usage of this architecture? More and more companies are asking for MVI as it suit pretty well with jetpack compose. I think lot of people would appreciate it. Thank y :-)!

    • @thishandleistaken.
      @thishandleistaken. Před 2 lety +5

      Great Idea, also I would like to see series or maybe a 3hour long video of him making a real app from absolute scratch (with setting up gradle, manifest file, all the implementations) and show the process of uploading it into play store

    • @kkp559
      @kkp559 Před 2 lety

      Did you read about Elmslie from vivid money? It’s good library to understand mvi flow

    • @dawidtyburek
      @dawidtyburek Před 2 lety

      This is an amazing MVI talk imho
      czcams.com/video/PXBXcHQeDLE/video.html

  • @anmolkulshrestha5855
    @anmolkulshrestha5855 Před 2 lety

    Thanks man

  • @datel666
    @datel666 Před 2 lety

    Nice vid!

  • @coffeebytez
    @coffeebytez Před 2 lety

    great video!

  • @stonedcodingtom9097
    @stonedcodingtom9097 Před 4 měsíci

    It helped me, bump

  • @safionweb
    @safionweb Před rokem

    Amazing

  • @ff2x701
    @ff2x701 Před rokem

    Thannkkk Yooouuuuu!!!!

  • @alexdelarge2584
    @alexdelarge2584 Před 2 lety

    Automatically like

  • @vinaykumarpatel649
    @vinaykumarpatel649 Před 2 lety

    Thanks

  • @sumukhaithal2819
    @sumukhaithal2819 Před 2 lety

    Simple and easy to understand. Thank you. Could you make a videos about applying pro guard and r8 for a project as well ?

  • @AdityaMishra-cj7kt
    @AdityaMishra-cj7kt Před 10 měsíci

    Awesome

  • @lee-zl2cu
    @lee-zl2cu Před 2 lety

    thank you

  • @gautamsharma7607
    @gautamsharma7607 Před 2 lety

    thanku so much

  • @hdkloh6857
    @hdkloh6857 Před 2 lety

    Nice video as always.... Android/Google team needs to make gradle thing similar to iOS... If a fresher gets a gradle sync failed error it's a nightmare for them....

  • @imnithish
    @imnithish Před 2 lety

    🔥

  • @TerryboyVictor
    @TerryboyVictor Před 2 lety

    On the Minimum SDK part, how do you then upload to the store targeting difference SDK if you can only upload one apk/bundle ?
    Or by building it packages both and on installing on individual device, it will target the device API and choose appropriately ?

  • @Basirafeef
    @Basirafeef Před rokem

    thanks for sharing great knowledge sir.
    sir i created an app for multiple people from the same source with different name, themes, server and google's .json configuration file. the problem is when i update one i need to update others too.
    is there a why to create multiple apps from the same source with different name, themes, server and google's .json configuration file from one project with different source sets.
    thanks.

  • @udaiti6784
    @udaiti6784 Před 5 dny

    For Android instrumentation test with release build, what build configuration does gradle use? Specifically what proguard file does it use?

  • @varshabhatia5487
    @varshabhatia5487 Před 2 lety

    Nice video. Thank you.
    I have a question: For example in my project I have 4 variants/ product flavours. I have one file which is already created in main folder but I want to use the same file with extra code for different product flavours. So is that possible via source set? I tried it but it won’t work.
    Example: I have xyz class in main folder. I cretaed 4 product flavours in build.gradle. Now I want to use the same xyz file with some extra code. I tried to copy and pasted the same file into newly created sourceset folder with some extra connection. But it won’t work that way.

  • @masoudfallahpour3650
    @masoudfallahpour3650 Před 2 lety +2

    Just a small correction. At 2:29 you say "package name" when highlighting the "applicationId" in the IDE. Package name is not the same thing as application ID.

  • @chanikafernando4928
    @chanikafernando4928 Před 2 lety

    Thank you for the cool video. I just encountered an issue after uograde to kotlin 1.6.10. i have fragments with tablayout and viewpager fragments. When i go to another screen and come back, it is not loading viewpager fragments. This happened after upgrading kotlin to 1.6.10. Do you have any idea why? Could you please help?

  • @salmaK20012
    @salmaK20012 Před rokem

    Hi, is ktor currently a good choice for backend development?

  • @alannelson4001
    @alannelson4001 Před rokem

    Two questions:
    1.) How do we define from where the implementations SDKs are pulled from? I know it's usually from maven repository but is it defined in the gradle someplace?
    2.) Does anyone have any good resources for establishing a "bypassLogin" build that would have all mock data provided for all API responses?

  • @user-kj8xk5qu2x
    @user-kj8xk5qu2x Před 2 lety +1

    Please Help
    I am new to this channel
    First I started learning kotlin language and fundamental tutorial and I am currently working on an application. Is the next step to learn Corotin Course or mvvm and add there are two mvvm series on the channel what is the difference between them
    thank you philipp

  • @clerdsonjuca3823
    @clerdsonjuca3823 Před 2 lety

    thanks ,videos CI/CD

  • @rafaelparanhos7435
    @rafaelparanhos7435 Před rokem

    Is there a way to config a flavor with plugin com.android.application and other flavor with com.android.library. If so, how to config it?

  • @oxitroy
    @oxitroy Před 2 lety +1

    I guess i'm missing something about products flavor and having one app that can have different minsdk ;
    If you have one product flavor with minSdk 21 and one with minSdk 18, when the app is released on store will it be available to phone with sdk 18 ?
    Even with product flavor you are forced to release 2 app with different minsdk, dont you?
    Great video as always

    • @PhilippLackner
      @PhilippLackner  Před 2 lety

      yes, but you still have one code base instead of two

  • @MrNDQuattro
    @MrNDQuattro Před rokem

    Thanks for the vid.
    Why would we need apks with different minSdk? Anyway we need to handle API check logic in code if we use new features.

    • @PhilippLackner
      @PhilippLackner  Před rokem +1

      If a whole feature is only for a certain min sdk, you don't want to include all that code in an app which can't even use that feature

  • @pickemparty
    @pickemparty Před 9 měsíci

    Can you show Generating Multiple APKs for Android ABIs (diff CPUs) in Gradle?!

  • @AndroidDojo
    @AndroidDojo Před 2 lety

    Wow, this is cool Man, can you create a GradleBasicplaylist please 🙏, this is soooooo important. There are no videos talking about Android Gradle exactly like this 😀.

  • @rapidretrovenue563
    @rapidretrovenue563 Před rokem

    does gradle HAVE to be in C drive? I need to move it to D, would that be possible? If so, how do I point to the directory? Thanks in advance everyone!

  • @manishakamble7473
    @manishakamble7473 Před měsícem

    👍

  • @astaghfirullahalzimastaghf3648

    bro please help me my gradle wrapper build fails

  • @erasmonepomuceno1719
    @erasmonepomuceno1719 Před 2 lety +1

    Hi Phillip, can you make a video how to use AD (Banner or Native) in recicleview but gettind data from api? I'm bennigner in android and i'm trying this, i see a lot tutorial but don't work with getting data from api

  • @astaghfirullahalzimastaghf3648

    i want to learn MVVM but i dont understand the code you wrote in the
    build.gradle (project) ..
    because it involves buildscript object and allprojects object..
    in my project it only contains plugins object..so that s why i am here

    • @rubinho388
      @rubinho388 Před rokem

      in recent android studio versions the items in the gradle are displayed a little bit differently from olders version. If you want to add buildScript to your project level gradle just add it above the plugins block

  • @MrOmsa12
    @MrOmsa12 Před 7 měsíci

    I did as you did in the tutorial but i could not use freeMinSdk21DebugImplementation, for some reason it did not work for me.

  • @pickemparty
    @pickemparty Před 9 měsíci

    Lastly, you didnt cover splits... is there a reason for that?

  • @kamertonaudiophileplayer847

    Awesome, more stupid system for building apps than Gradle I never met. Nice,that somebody tried to explain it.

  • @BlackSkyCrew
    @BlackSkyCrew Před rokem

    I'm completely newby in this topic. And I have problems with run your old and new examples from Github. I don't undestand how people maintains android projects, if when I or someone else try to run this project on his local mashine and need to fight with many buid issues, which is not have relation to real code writing. This is a big pain in my life now...

  • @quantumgaming7
    @quantumgaming7 Před 2 lety

    It that course price really 28900 euros??

    • @quantumgaming7
      @quantumgaming7 Před 2 lety

      If it is in India it’s like 2.4 Millions an average person don’t even earn that much in there entire life 🌝

  • @h4ktbtw
    @h4ktbtw Před 2 lety

    Gradle takes endless time to build?
    Oh boy, have you ever used Maven to build Java/Kotlin project?

  • @WeslleyCampos-kw3pm
    @WeslleyCampos-kw3pm Před rokem

    Clean Task is no longer necessary, it's default now.

  • @ReddSpark
    @ReddSpark Před rokem

    Had to wait till 2:20 to actually find an answer to "What the fook is gradle?"

  • @AnB-em9wo
    @AnB-em9wo Před 7 měsíci

    I recommend you upgrade your microphone. Sound quality on your channel is no good

  • @marvelrivera1194
    @marvelrivera1194 Před 5 měsíci

    I hate gradle

  • @jopadjr
    @jopadjr Před 2 lety

    Hi Philipp, after a year of absence in the Android development, I noticed the build.gradle project level has a different setup. It was like this before with dependencies, etc.
    dependencies {
    classpath 'com.android.tools.build:gradle:7.2.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
    Was there an explanation (been googling for answers) on converting this to the new format shown at 2:45? Thanks in advance