Pro Your skills of Gradle use in Android Studio


Download 323.31 Kb.
bet1/5
Sana18.06.2023
Hajmi323.31 Kb.
#1578235
  1   2   3   4   5

Pro Your skills of Gradle use in Android Studio





Rajesh Tiwari
·
Follow
6 min read
·
Nov 17, 2017

Gradle is one of the building blocks for creating Android application, it contains information regarding application flavors, information, library uses in the project and lots of other information which you will let you know in a few pages to go.
Mostly we see below two. grade file in the project, which are used differently

  • build.gradle

  • setting.gradle

You will get this information in details in a few minutes, firstly focus on some use and common errors while developing.
Use common properties for all dependencies and default configs
Case 1:
While development big projects which contains modules and common dependency, we stuck in situation like some module use minSdk:14, minSdk:16, minSdk:11 and our main project contains minSdk: 11 and when we try to build project gradle it throws an error “minSdk require to build project is 14 and your min is 11”.
Solution:
To resolve this issue we define all the common properties in project level gradle with ext tag

Now to access these properties through module level gradle

As you see the changes in app gradle like we didn’t place any int value their we refer the common properties defined in ext section.
Case 2:
As dependencies are frequently updated with each SDK release like if you using google play services like maps, gcm, location. If we want to update these libraries then we traverse to each line which contains play services and update them.
Solution:
To access the common dependencies refer them with variable name in double inverted quotes

Case 3:
Want to keep the variable change for different flavours and access globally.
Solution:
BuildConfigField is used to define variables which will accessible globally throughout the app. You can access this part in the .java code with Build Config. BASE_URL_MAIN.


Download 323.31 Kb.

Do'stlaringiz bilan baham:
  1   2   3   4   5




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling