Gradle is a build tool for Android development to manage and build apps. It compiles the app’s code that is written in Java or Kotin languages. And it was compiling, linking, packaging the code that is converted into APK files.
Two levels of Gradle files are there. Let’s see a detailed view of them.
1. Top-level Gradle file
2. Module-level Gradle file
Top-level Gradle file
The top-level Gradle file resides within your application’s root folder and is crucial for configuring all modules within your application.
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {}
}
allprojects {}
}
rootProject.buildDir = '../build'
subprojects {}
task clean(type: Delete) {
delete rootProject.buildDir
}
The top-level Gradle build script contains configurations related to repositories and dependencies needed throughout the application’s build process.
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
android {}
kotlinOptions {
jvmTarget = '1.8'
}
defaultConfig {}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {}
Min-SDK Version
Min-SDK contains a minimum level of API support for the application. For example, if you are setting the version as 13, your released version of APK will support only 13 or above versions.
Target-SDK Version
This API level is mentioned to test the application. if you are are going to set the version as 21 then the build supports up to 21.
Version Code & Version Name
This should be increased by one while updating the application.
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.dark_light_theme"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Conclusion
Both scripts are used to automate the tasks and generate the APK file from the source file. And it can be modified in several ways like Java, and Groovy. And also, the performance of Gradle is very fast and efficient. This is twice the speed of Maven and hundreds of times the speed of building a cache.
No Comment! Be the first one.