Skip to content

Commit

Permalink
downgrade android gradle plugin version & modify gradle let AS 4.0.X~…
Browse files Browse the repository at this point in the history
…4.2.X stable version support compose
  • Loading branch information
CMingTseng committed Jun 30, 2021
1 parent f939fa7 commit 5063e48
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
36 changes: 33 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,36 @@ plugins {
id 'com.android.application'
id 'kotlin-android'
}
def android_builder_version = "4.0.1"

ext {
android_builder_main_version = Integer.parseInt(android_builder_version.split("\\.")[0])
android_builder_mid_version = Integer.parseInt(android_builder_version.split("\\.")[1])
}

android {
this.rootProject.buildscript.configurations.classpath
.resolvedConfiguration
.firstLevelModuleDependencies.
each {
def name = it.name
if (name.contains('com.android.tools.build:gradle')) {
def moduleVersion = it.moduleVersion
if (moduleVersion.contains("-")) {
def alphaversionArray = moduleVersion.split("-")[0]
def versionArray = alphaversionArray.toString().split("\\.")
ext.android_builder_main_version = Integer.parseInt(versionArray[0])
ext.android_builder_mid_version = Integer.parseInt(versionArray[1])
} else {
version = moduleVersion
android_builder_version = moduleVersion
ext.android_builder_main_version = Integer.parseInt(android_builder_version.split("\\.")[0])
ext.android_builder_mid_version = Integer.parseInt(android_builder_version.split("\\.")[1])
}
}
}
compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.example.androiddevchallenge"
Expand Down Expand Up @@ -38,11 +65,13 @@ android {

kotlinOptions {
jvmTarget = "1.8"
useIR = true
}

buildFeatures {
compose true

if (android_builder_main_version >= 7 || (android_builder_main_version > 4 && android_builder_mid_version > 3)) {
compose true
}
// Disable unused AGP features
buildConfig false
aidl false
Expand All @@ -53,6 +82,7 @@ android {

composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion kotlin_version
}

packagingOptions {
Expand All @@ -76,7 +106,7 @@ dependencies {
implementation "androidx.compose.material:material-icons-extended:$compose_version"
implementation "androidx.navigation:navigation-compose:$compose_navigation_version"

implementation "dev.chrisbanes.accompanist:accompanist-insets:0.6.2"

testImplementation 'junit:junit:4.13.2'

androidTestImplementation 'androidx.test.ext:junit:1.1.2'
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

buildscript {
ext {
android_gradle_plugin_version = '7.0.0-alpha09'
android_gradle_plugin_version = '4.1.2'
kotlin_version = '1.5.10'
coroutines_version = '1.4.3'

Expand Down

0 comments on commit 5063e48

Please sign in to comment.