0

I have Two lines of error when i run the simple Jetpack Compose Material 3 Project

build.gradle(Project:)

    buildscript {
    ext {
        compose_version = '1.3.0-beta02'
        core_ktx_version = '1.9.0-rc01'
        material3_version = 'material3:1.3.0-beta02'
        lifecycle_version =  '2.4.1'
        activity_compose_version = '1.5.1'
        nav_version = "2.5.2"
        hilt_version = "2.42"
        hilt_nav_fragment = "1.0.0"
        lottieVersion = "5.2.0"
        timber_version = "5.0.1"
        hilt_navigation_compose = "1.0.0"
        room_version = "2.3.0-beta02"
        kotlin_version = "1.6.21"
    }
    dependencies {

        classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
        classpath "com.android.tools.build:gradle:4.2.1"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.2.2' apply false
    id 'com.android.library' version '7.2.2' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}

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

build.gradle (Module : )

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

android {
    compileSdk 33

    defaultConfig {
        applicationId "com.jetpackcompose.jp1"
        minSdk 24
        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 {
        kotlinCompilerExtensionVersion compose_version
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {

    implementation "androidx.core:core-ktx:$core_ktx_version"
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material3:$material3_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
    implementation "androidx.activity:activity-compose:$activity_compose_version"

    implementation "androidx.compose.compiler:compiler:1.3.1"
    implementation 'androidx.appcompat:appcompat:1.6.0-beta01'
    // hilt -android
    implementation "com.google.dagger:hilt-android:$hilt_version"
    kapt "com.google.dagger:hilt-android-compiler:$hilt_version"

    // To Integrate Navigation
    implementation "androidx.navigation:navigation-compose:$nav_version"

    // To use additional extensions of navigation frameworks like hiltViewModel()
    implementation "androidx.hilt:hilt-navigation-fragment:$hilt_nav_fragment"
    implementation "androidx.hilt:hilt-navigation-compose:$hilt_navigation_compose"
    implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
    implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

    testImplementation 'junit:junit:4.13.2'
    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"
    debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
 }

settings.gradle:

    pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
    }
}
rootProject.name = "jp1"
include ':app'

when i run the project i have an error of :

Execution failed for task ':app:desugarDebugFileDependencies'.

Could not resolve all files for configuration ':app:debugRuntimeClasspath'. Could not find androidx.compose.material3:material3:1.3.0-beta02.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
SasidharanIOS
  • 252
  • 1
  • 3
  • 12

2 Answers2

4

Compose compiler and the other compose dependencies have different releases.
The version androidx.compose.compiler:compiler:1.3.0-beta02 doesn't exist.
You can check it in the google maven repo

You can in any case use the stable version of the module compiler 1.3.1 and all the other compose dependencies at 1.2.1 or 1.3.0-beta02:

buildscript {
    ext {
        compose_compiler = '1.3.1'         //compiler
        compose_version = '1.3.0-beta02'   //compose dependencies
        compose_material3 = '1.0.0-beta02' //material3 release
    }
    //...
}

and then:

composeOptions {
    kotlinCompilerExtensionVersion compose_compiler
}

dependencies {
   // beta 1.3.0 releases
   implementation "androidx.compose.material:material:$compose_version"
   //... 

   //material3
   implementation "androidx.compose.material3:material3:$compose_material3"
}

As described in the documentation the compiler 1.3.x requires kotlin 1.7.10:

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find androidx.compose.material3:material3:1.3.0-beta02. Again I got error like this @Gabriele Mariotti – SasidharanIOS Sep 12 '22 at 09:05
  • 1
    @SasidharanIOS Because material3 1.3.0 doesn't exist. You have to check your dependencies: https://developer.android.com/jetpack/androidx/releases/compose-material3 – Gabriele Mariotti Sep 12 '22 at 09:11
  • 1
    Working fine ..Thanl you so much @Gabriele Mariotti – SasidharanIOS Sep 12 '22 at 09:57
0

I tried to use 2.42 for androidx.hilt:hilt-navigation-compose and getting error. I use 1.0.0 version and it works. Check all your dependencies last versions from Maven Repository.

Maven Repository