diff --git a/app/build.gradle b/app/build.gradle index 8a5e78f..0e02eed 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,10 +1,35 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' +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 "29.0.2" + buildToolsVersion "30.0.3" defaultConfig { applicationId "com.example.jetpackcomposeplayground" @@ -26,17 +51,17 @@ android { sourceCompatibility = 1.8 targetCompatibility = 1.8 } - kotlinOptions { - jvmTarget = '1.8' - } + buildFeatures { - compose true + if (android_builder_main_version >= 7 || (android_builder_main_version > 4 && android_builder_mid_version > 1)) { + compose true + } } composeOptions { kotlinCompilerVersion "${versions.kotlinCompilerVersion}" kotlinCompilerExtensionVersion "${versions.compose}" - } + // Added to avoid this error - // Execution failed for task ':app:mergeDebugAndroidTestJavaResource'. // > A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction @@ -76,6 +101,9 @@ dependencies { implementation deps.coroutine.core // Compose + if (android_builder_main_version < 7) { + add("kotlinCompilerPluginClasspath", "androidx.compose.compiler:compiler:${versions.compose}") + } implementation deps.compose.activityCompose implementation deps.compose.composeRuntime implementation deps.compose.constraintLayout diff --git a/build.gradle b/build.gradle index 097b3a8..5a051f8 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ buildscript { 'coroutine': '1.3.7', 'espresso': '3.2.0', 'glide': '4.10.0', - 'gradle': '7.0.0-beta03', + 'gradle': '4.1.2', 'junit' : '4.12', 'junitImplementation' : '1.1.1', 'kotlin': '1.5.10', @@ -20,7 +20,7 @@ buildscript { 'ktxSupport': '2.2.0', 'lifecycle':'2.2.0', 'picasso': '2.71828', - 'supportLibrary': '1.1.0', + 'supportLibrary': '1.3.0', 'testRunner': '1.2.0', ] ext.deps = [ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 179e1b2..a32a9af 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip