Reputation: 496
Recently Jetpack Compose 1.5 was released, adding a dependency either using the compose POM
implementation(platform("androidx.compose:compose-bom:2023.08.00"))
or directly using
implementation("androidx.compose.ui:ui:1.5.0")
to a project using compileSDK = 33 results in two dependency issues
Using API SDK 34, is currently not possible since there is no publicly available version of the android gradle plugin that supports it and secondly API 34 is still in beta.
Since I don't directly use the emoji2 dependency anywhere, this can be fixed using a build.gradle.kts similiar to the following.
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}
android {
namespace = "com.example.myapplication"
compileSdk = 33
defaultConfig {
configurations.all {
resolutionStrategy {
force("androidx.emoji2:emoji2-views-helper:1.3.0")
force("androidx.emoji2:emoji2:1.3.0")
}
}
applicationId = "com.example.myapplication"
minSdk = 24
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
dependencies {
implementation("androidx.core:core-ktx:1.10.1")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
implementation("androidx.activity:activity-compose:1.7.2")
implementation(platform("androidx.compose:compose-bom:2023.08.00"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3:1.1.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2023.08.00"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest:1.5.0")
}
Is this the best way to fix this issue, is this a dependency bug since all the dependencies are marked as stable but one of them has a dependency on a beta SDK. Incidentally, the emoji2 dependency is marked as requiring a minSdkVersion of 14, not 34.
The following issue was created on the google tracker by someone else as I was creating this question, I also encountered this issue with Kotlin plugin version 1.8.20.
https://issuetracker.google.com/issues/295457468
Upvotes: 26
Views: 6005
Reputation: 3262
For some newer Library versions, you have to use the latest CompileSDK Version. Add Below Code In build.gradle(app-level)
in defaultConfig
.
android {
defaultConfig {
...
compileSdkPreview = "UpsideDownCake"
...
}
}
Upvotes: 10