Search code examples
androidkotlinandroid-jetpackandroid-jetpack-compose

Gradle can't find kotlin compiler version


I wanted to configure Jetpack Compose. I did it but during running the app I get that error everytime. Jetpack is in the project and I can use it but I can't run the app.

Execution failed for task ':myModule:prepareDebugKotlinCompileTask'.

Could not resolve all files for configuration ':myModule:kotlin-extension'. Could not find androidx.compose:compose-compiler:1.0.0-alpha05. Searched in the following locations: - https://dl.google.com/dl/android/maven2/androidx/compose/compose-compiler/1.0.0-alpha05/compose-compiler-1.0.0-alpha05.pom

My module's Gradle file:

plugins {
    id("po-android-library")
    id("kotlin-kapt")
    id("de.mannodermaus.android-junit5")
}

android {
    defaultConfig {
        renderscriptTargetApi = AndroidSdkVersions.target
        renderscriptSupportModeEnabled = true
        vectorDrawables.useSupportLibrary = true
    }

    buildFeatures {
        compose = true
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    composeOptions {
        kotlinCompilerVersion = "1.4.0"
        kotlinCompilerExtensionVersion = "1.0.0-alpha05"
    }

    kotlinOptions {
        jvmTarget = "1.8"
        useIR = true
    }


    testOptions.unitTests.isIncludeAndroidResources = true

    sourceSets {
        val sharedTestDir = "src/sharedTest/java"

        getByName("test") {
            java.srcDir(sharedTestDir)
        }
    }

    packagingOptions {
        pickFirst("mockito-extensions/org.mockito.plugins.MockMaker")
        exclude("META-INF/rxjava.properties")
        exclude("META-INF/rxkotlin.properties")
    }
}

dependencies {
    implementation(project(":common"))
    implementation(project(":android-common"))

    implementation(Deps.kotlin_stdlib)

    implementation("com.android.tools.build:gradle:4.1.0")
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10")

    implementation(Deps.androidx_appcompat)
    implementation(Deps.koin_android_viewmodel)
    implementation(Deps.koin_androidx_ext)
    implementation(Deps.koin_android)
    implementation(Deps.rxkotlin)

    implementation("androidx.compose.runtime:runtime:1.0.0-alpha05")
    implementation("androidx.compose.ui:ui:1.0.0-alpha05")
    implementation("androidx.compose.foundation:foundation-layout:1.0.0-alpha05")
    implementation("androidx.compose.material:material:1.0.0-alpha05")

Solution

  • From Compose compiler version 1.0.0-alpha04, we should use Android Studio 4.2 Canary 13 or later and com.android.tools.build:gradle version should be 4.2.0-alpha13

    From the Official site reference