Home > Software engineering >  Please what dependency is missing or confliting for safe args
Please what dependency is missing or confliting for safe args

Time:02-23

I am learning some kotlin concepts. I don't really understand yet.

I added SafeArgs classpath and plugin to the appropriate build.gradle file.

Here's the classpath:

classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.1"

And Here's the plugin

id 'androidx.navigation.safeargs.kotlin'

Even After this I still get an missing or conflicting dependencies error

Cannot access class 'com.example.testingtaskmanager.ui.updatefragment.UpdateFragmentArgs'. Check your module classpath for missing or conflicting dependencies

I now understand that the SafeArgs needs to be in a consistent version with some other dependiency, but I am not really similar with this.

Here's a picture of the error for clarify sake; enter image description here

So please I am going to link all my build.gradle file both app and project level, so you can take a look at it, if it's not too much to ask.. Thanks in Advance.

build.gradle app level;

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'


    //
//    id "androidx.navigation.safeargs"
    id 'androidx.navigation.safeargs.kotlin'
    id 'kotlin-parcelize'
}

android {
    compileSdk 31

    defaultConfig {
        applicationId "com.example.testingbottomnav"
        minSdk 21
        targetSdk 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    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 {
        dataBinding true
        viewBinding true
    }
    packagingOptions {
        exclude 'META-INF/atomicfu.kotlin_module'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation "androidx.constraintlayout:constraintlayout:$constraintlayout_version"
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4. '
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

    implementation 'androidx.cardview:cardview:1.0.0'
    implementation "androidx.recyclerview:recyclerview:1.2.1"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.0"

    //Material Components
    implementation 'com.google.android.material:material:1.4.0'

    // Navigation Component
    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
    implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'

    // Added for To-Do List

    // Dependencies for working with Architecture components
    // You'll probably have to update the version numbers in build.gradle (Project)

    implementation fileTree(dir: "libs", include: ["*.jar"])
//    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.4.31"
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'

    // Room components
    implementation "androidx.room:room-runtime:2.2.6"
    kapt "androidx.room:room-compiler:2.2.6"
    implementation "androidx.room:room-ktx:2.2.6"
    androidTestImplementation "androidx.room:room-testing:2.2.6"

    // Lifecycle components
    implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
    implementation "androidx.lifecycle:lifecycle-common-java8:2.3.0"


    // Kotlin components
    api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2"
    api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2"

    // DataBinding
    kapt "com.android.databinding:compiler:3.2.0-alpha10"
    kapt "androidx.databinding:databinding-common:4.1.2"

    // RecyclerView Animator
    implementation 'jp.wasabeef:recyclerview-animators:3.0.0'
}

build.gradle project level;

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext {
        appcompat_version = "1.2.0"
        constraintlayout_version = "2.0.2"
        core_ktx_version = "1.3.2"
        kotlin_version = "1.3.72"
        material_version = "1.2.1"

        nav_version = "2.3.1"
    }

    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.3"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20"

        //
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.1"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

I'd really apppreciate any help, Thanks so much in advance. If you need any information I am more than happ to provide.

Thanks again.

CodePudding user response:

Have you tried using the same version for the plugin as you use for navigation right now you have 2.3.1 for safeargs and 2.3.5 for base navigation dependency.

classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.1"

// Navigation Component
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'

CodePudding user response:

You must have android.useAndroidX=true in your gradle.properties file

Dependency Changes for version 2.3.1

  • navigation-ui now depends on DrawerLayout 1.1.1
  • Safe Args now depends on KotlinPoet 1.6.0
  • Safe Args now depends on AGP 4.0.1 (android gradle plugin)

Check the following page and the related samples on github

  • Related