construct.gradle.kts conversion for Android Studio Empty Process




construct.gradle.kts conversion for Android Studio Empty Process


Fast weblog posting appearing you the construct.gradle.kts model of the default construct.gradle document from the ‚Äúempty exercise‚ÄĚ Android Studio template.

This put up will cross stale speedy, get it while its scorching. ūüôā

The unique templates come from the New Venture, different templates are defined right here: https://developer.android.com/studio/tasks/templates

Google has an explainer of changing construct configuration scripts from Groovy to Kotlin: https://developer.android.com/construct/migrate-to-kotlin-dsl

Gradle has a primer for appearing what construct.gradle instructions in Groovy appear to be in Kotlin construct.gradle.kts information: https://medical doctors.gradle.org/present/userguide/kotlin_dsl.html

In spite of everything Google introduced that Kotlin construct.gradle.kts will be the new default for construct configuration information: https://android-developers.googleblog.com/2023/04/kotlin-dsl-is-now-default-for-new-gradle-builds.html

This is the present new mission Groovy construct.gradle document:

Groovy DSL

plugins {
   identification 'com.android.software'
   identification 'org.jetbrains.kotlin.android'
}

android {
   namespace 'com.blundell.demo'
   compileSdk 33
   defaultConfig {
       applicationId "com.blundell.demo"
       minSdk 29
       targetSdk 33
       versionCode 1
       versionName "1.0"
       testInstrumentationRunner "androidx.check.runner.AndroidJUnitRunner"
       vectorDrawables {
           useSupportLibrary true
       }
   }
   buildTypes {
       liberate {
           minifyEnabled false
           proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.professional'
       }
   }
   compileOptions {
       sourceCompatibility JavaVersion.VERSION_1_8
       targetCompatibility JavaVersion.VERSION_1_8
   }
   kotlinOptions {
       jvmTarget="1.8"
   }
   buildFeatures {
       compose true
   }
   composeOptions {
       kotlinCompilerExtensionVersion '1.3.2'
   }
   packagingOptions {
       sources {
           excludes += '/META-INF/{AL2.0,LGPL2.1}'
       }
   }
}

dependencies {
   implementation 'androidx.core:core-ktx:1.8.0'
   implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.0')
   implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
   implementation 'androidx.exercise:activity-compose:1.5.1'
   implementation platform('androidx.compose:compose-bom:2022.10.00')
   implementation 'androidx.compose.ui:ui'
   implementation 'androidx.compose.ui:ui-graphics'
   implementation 'androidx.compose.ui:ui-tooling-preview'
   implementation 'androidx.compose.material3:material3'
   testImplementation 'junit:junit:4.13.2'
   androidTestImplementation 'androidx.check.ext:junit:1.1.5'
   androidTestImplementation 'androidx.check.coffee:espresso-core:3.5.1'
   androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00')
   androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
   debugImplementation 'androidx.compose.ui:ui-tooling'
   debugImplementation 'androidx.compose.ui:ui-test-manifest'
}

>> You most likely are on the lookout for this KTS <<

And here’s the Kotlin construct.gradle.kts model.

Kotlin DSL

plugins {
   identification("com.android.software")
   identification("org.jetbrains.kotlin.android")
}

android {
   namespace = "com.blundell.demo"
   compileSdkVersion(33)
   defaultConfig {
       applicationId = "com.blundell.demo"
       minSdk = 29
       targetSdk = 33
       versionCode = 1
       versionName = "1.0"
       testInstrumentationRunner = "androidx.check.runner.AndroidJUnitRunner"
       vectorDrawables {
           useSupportLibrary = true
       }
   }

   buildTypes {
       liberate {
           isMinifyEnabled = false
           proguardFiles(
               getDefaultProguardFile("proguard-android-optimize.txt"),
               "proguard-rules.professional"
           )
       }
   }
   compileOptions {
       sourceCompatibility = JavaVersion.VERSION_11
       targetCompatibility = JavaVersion.VERSION_11
   }
   kotlinOptions {
       jvmTarget = "11"
   }
   buildFeatures {
       compose = true
   }
   composeOptions {
       kotlinCompilerExtensionVersion = "1.3.2"
   }
   packagingOptions {
       sources {
           excludes += listOf("/META-INF/{AL2.0,LGPL2.1}")
       }
   }
}

dependencies {
   implementation("androidx.core:core-ktx:1.8.0")
   implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
   implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1")
   implementation("androidx.exercise:activity-compose:1.5.1")
   implementation(platform("androidx.compose:compose-bom:2022.10.00"))
   implementation("androidx.compose.ui:ui")
   implementation("androidx.compose.ui:ui-graphics")
   implementation("androidx.compose.ui:ui-tooling-preview")
   implementation("androidx.compose.material3:material3")
   debugImplementation("androidx.compose.ui:ui-tooling")
   debugImplementation("androidx.compose.ui:ui-test-manifest")
   testImplementation("junit:junit:4.13.2")
   androidTestImplementation("androidx.check.ext:junit:1.1.5")
   androidTestImplementation("androidx.check.coffee:espresso-core:3.5.1")
   androidTestImplementation(platform("androidx.compose:compose-bom:2022.10.00"))
   androidTestImplementation("androidx.compose.ui:ui-test-junit4")
}

Hope that fast conversion to Kotlin construct.gradle.kts is helping you! And expectantly this weblog put up shall be deprecated after they replace the templates to create Kotlin construct Gradle information. ūüôā



You May Also Like

More From Author

+ There are no comments

Add yours