Pierre Vieira
Pierre Vieira

Reputation: 3300

Error resolving jetpack compose dependencies in version 1.1.0-rc02

Problem description

I'm trying to use the latest version of jetpack compose 1.1.0-rc02, but some dependencies are returning an error:

Failed to resolve: androidx.compose.material:material:1.1.0-rc02
Failed to resolve: androidx.compose.ui:ui:1.1.0-rc02
Failed to resolve: androidx.compose.ui:ui-tooling:1.1.0-rc02
Failed to resolve: androidx.compose.ui:ui-tooling-preview:1.1.0-rc02
Failed to resolve: androidx.compose.ui:ui-test-junit4:1.1.0-rc02

My gradle files

Project scope

buildscript {
    ext {
        compose_version = '1.1.0-rc02'
        kotlin_version = '1.6.10'
        hilt_version = '2.38.1'
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.4"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}


task clean(type: Delete) {
    delete rootProject.buildDir
}

Application scope

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id 'dagger.hilt.android.plugin'
}

android {
    compileSdk 31

    defaultConfig {
        applicationId "com.plcoding.dictionary"
        minSdk 21
        targetSdk 31
        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'
        useIR = true
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
        kotlinCompilerVersion kotlin_version
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'
    implementation 'androidx.activity:activity-compose:1.4.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"

    // Compose dependencies
    implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0"

    // Coroutines
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'

    // Coroutine Lifecycle Scopes
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0"

    //Dagger - Hilt
    implementation "com.google.dagger:hilt-android:$hilt_version"
    kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
    implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03"
    kapt "androidx.hilt:hilt-compiler:1.0.0"
    implementation 'androidx.hilt:hilt-navigation-compose:1.0.0-rc01'

    // Retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.2"
    implementation "com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2"

    // Room
    implementation "androidx.room:room-runtime:2.4.0"
    kapt "androidx.room:room-compiler:2.4.0"

    // Kotlin Extensions and Coroutines support for Room
    implementation "androidx.room:room-ktx:2.4.0"
}

Upvotes: 1

Views: 3639

Answers (2)

Nishant Srivastava
Nishant Srivastava

Reputation: 4791

Here is a code version of the same answer @Francesc gave:

// Inside project's build.gradle file
buildscript {
    ext {
       // Define the 2 versions
       compose_compiler_version = '1.1.0-rc02'
       compose_version = '1.1.0-rc01'
    }
 ...
}

Then inside your android module (app/library):

// Inside module's build.gradle file
android {
   ...
   composeOptions {
         // Compose compiler uses 'compose_compiler_version'
         kotlinCompilerExtensionVersion compose_compiler_version
   }
}

dependencies {
   ...

   // Compose dependencies use 'compose_version'
   implementation "androidx.compose.ui:ui:$compose_version"
   implementation "androidx.compose.material:material:$compose_version"
   implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
   androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
   debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
}

Upvotes: 7

Francesc
Francesc

Reputation: 29260

RC02 is only available for the compose compiler to make it compatible with Kotlin 1.6.10. All other libraries are still in RC01, so for now you have to specify different versions for the compiler and the other compose dependencies.

Upvotes: 4

Related Questions