Stephan
Stephan

Reputation: 16789

Jetpack compose compiler cannot be resolved

I tried to add jetpack compose to an existing project. I added jetpack compose to my gradle file:

buildFeatures {
     compose = true
}
compileOptions {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions { jvmTarget = "1.8" }

composeOptions {
    kotlinCompilerExtensionVersion composeVersion
}

//to the dependencies
implementation "androidx.compose.compiler:compiler:$composeVersion"
    // Tooling support (Previews, etc.)
    implementation "androidx.compose.ui:ui-tooling:$composeVersion"
    // Foundation (Border, Background, Box, Image, Scroll, shapes, animations, etc.)
    implementation "androidx.compose.foundation:foundation:$composeVersion"
    // Material Design
    implementation "androidx.compose.material:material:$composeVersion"
    implementation "androidx.activity:activity-compose:1.3.0-beta02"
    implementation "androidx.compose.runtime:runtime-livedata:$composeVersion"

When I try to build my project I get an error:

Execution failed for task ':app:prepareAcceptanceDebugKotlinCompileTask'.
> Could not resolve all files for configuration ':app:kotlin-extension'.
   > Could not resolve androidx.compose:compose-compiler:1.0.0-beta09.
     Required by:
         project :app
      > No cached version of androidx.compose:compose-compiler:1.0.0-beta09 available for offline mode.
      > No cached version of androidx.compose:compose-compiler:1.0.0-beta09 available for offline mode.
      > No cached version of androidx.compose:compose-compiler:1.0.0-beta09 available for offline mode.
      > No cached version of androidx.compose:compose-compiler:1.0.0-beta09 available for offline mode.
      > No cached version of androidx.compose:compose-compiler:1.0.0-beta09 available for offline mode.
      > No cached version of androidx.compose:compose-compiler:1.0.0-beta09 available for offline mode.
      > No cached version of androidx.compose:compose-compiler:1.0.0-beta09 available for offline mode.
      > No cached version of androidx.compose:compose-compiler:1.0.0-beta09 available for offline mode.
      > No cached version of androidx.compose:compose-compiler:1.0.0-beta09 available for offline mode.
      > No cached version of androidx.compose:compose-compiler:1.0.0-beta09 available for offline mode.
      > No cached version of androidx.compose:compose-compiler:1.0.0-beta09 available for offline mode.
      > No cached version of androidx.compose:compose-compiler:1.0.0-beta09 available for offline mode.

Possible solution:
 - Disable offline mode and rerun the build

I checked and there is no such thing as an androidx.compose:compose-compiler:1.0.0-beta09 there is only a 1.0.0-alpha03 version of this available here.

Printing the gradle dependencies I get this:

kotlin-extension - Configuration for Compose related kotlin compiler extension
\--- androidx.compose:compose-compiler:1.0.0-beta09 FAILED

What can I do to solve this issue, and where is it coming from?

Upvotes: 1

Views: 808

Answers (2)

Hans
Hans

Reputation: 1915

in your main build.gradle set

dependencies {
        classpath 'com.android.tools.build:gradle:7.0.0-beta04'
        ...
}

and set your gradle-wrapper.properties to:

distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip

Upvotes: 1

Fahime Zivdar
Fahime Zivdar

Reputation: 431

first step, disable the offline mode. then you should delete folder .gradle

e.g C:\Users\youruser(.gradle)

Upvotes: 1

Related Questions