Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify gradle setting let AS 4.0.X~4.2.X stable version support compose #90

Open
wants to merge 5 commits into
base: vinay-latest-compose
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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