While building gradle I encounter a warning: Failed to resolve: androidx.compose.ui:ui-tooling and recommends adding Google maven repository but this is already specified in settings.gradle. I tried different versions for compose_ui_version and kotlin compiler extension version. How can I resolve this issue?
buildscript {
ext {
compose_ui_version = "1.4.0-alpha05"
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
}
and app's build.gradle:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
namespace 'com.example.bettehomes'
compileSdk 33
defaultConfig {
applicationId "com.example.bettehomes"
minSdk 25
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled 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 {
kotlinCompilerVersion "1.7.20"
kotlinCompilerExtensionVersion "1.4.0-beta05"
}
packagingOptions {
resources {
excludes = '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
def composeBom = platform("androidx.compose.compose-bom:2022.12.00")
implementation composeBom
androidTestImplementation composeBom
implementation 'com.google.maps.android:maps-compose'
implementation 'com.google.android.gms:play-services-maps'
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation 'androidx.activity:activity-compose'
implementation "androidx.compose.ui:ui-tooling"
implementation "androidx.compose.ui:ui-tooling-preview"
implementation 'androidx.compose.material3:material3'
// Android Studio Preview Support
debugImplementation "androidx.compose.ui:ui-tooling"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation "androidx.compose.ui:ui-test-junit4"
debugImplementation "androidx.compose.ui:ui-test-manifest"
}
CodePudding user response:
Have you tried adding the following into the buildscript
section inside your project level gradle file?
repositories {
mavenCentral()
}
CodePudding user response:
I was having the same problem. Eventually I tried to add the version explicitly like this:
implementation "androidx.compose.ui:ui-tooling-preview:1.3.2"
Notice that 1.3.2 is the version imported by the BOM version you are using.
Obviously it was still not working but at least now I got a more descriptive error message.
It turned out I need compileSdkVersion 33
(I was using 31).
Since I don't want to increment yet my compileSdkVersion, I will have to downgrade ui-tooling-preview
to explicitly use version 1.1.1
I can see you are already using compileSdkVersion 33
, however adding explicitly the version might help you get a more descriptive error message.