Home > OS >  Caused by: org.gradle.plugin.internal.InvalidPluginIdException: plugin id 'androidx.navigation:
Caused by: org.gradle.plugin.internal.InvalidPluginIdException: plugin id 'androidx.navigation:

Time:07-02

I am developing new android app where I am using android navigation component but when I run the project I am getting following Caused by: org.gradle.plugin.internal.InvalidPluginIdException: plugin id 'androidx.navigation:navigation-safe-args-gradle-plugin' is invalid

below my build.gradle

plugins {
    id 'com.android.application' version '7.1.3' apply false
    id 'com.android.library' version '7.1.3' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
    id 'androidx.navigation:navigation-safe-args-gradle-plugin' version '2.5.0' apply false
}

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

below my app.gradle

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'
    id 'androidx.navigation.safeargs'
    id 'kotlin-parcelize'
   // id 'kotlin-android'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.example.newsapp"
        minSdk 21
        targetSdk 32
        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'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.8.0'
    implementation 'androidx.appcompat:appcompat:1.4.2'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'


    def koin_version = "3.2.0"
    def lifecycle_version = "2.5.0"
    implementation 'androidx.core:core-ktx:1.8.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0")

    //retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.jakewharton.espresso:okhttp3-idling-resource:1.0.0'
    //  implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-com.example.newsworldwide.ui.adapter:0.9.2"
    implementation 'com.squareup.okhttp3:okhttp:4.9.1'
    //Logging
    implementation 'com.squareup.okhttp3:logging-interceptor:4.5.0'

    //implementation 'com.github.jakewharton:retrofit2-kotlin-coroutines-adapter:1.0.0'
    // Koin Version
    implementation "io.insert-koin:koin-android:$koin_version"
    implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version")
    //        // ViewModel utilities for Compose
    // LiveData
    implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version")
    // Lifecycles only (without ViewModel or LiveData)
    implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version")
    // Saved state module for ViewModel
    implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version")


    implementation 'androidx.annotation:annotation:1.3.0'

    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'de.hdodenhof:circleimageview:3.1.0'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.5.0'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.5.0'
    implementation 'androidx.navigation:navigation-ui-ktx:2.5.0'


    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

I have tried all stackoverflow answers it did not help at all even this link as well Could not find androidx.navigation:safe-args-gradle-plugin:1.0.0-alpha01 I want to know where exactly I am making mistake what I have to do in order fix the issue

CodePudding user response:

Add this on the top of your build.gradle:

buildscript {
    dependencies {
        classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.5.0'
    }
}

So your build.gradle should look like this:

buildscript {
    dependencies {
        classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.5.0'
    }
}

plugins {
    id 'com.android.application' version '7.1.3' apply false
    id 'com.android.library' version '7.1.3' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}

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