Plugin with id 'androidx.navigation.safeargs' not found

Viewed 44907

When I try to add Safe Args (Android Navigation) to my app's as following

( using this guide : https://developer.android.com/topic/libraries/architecture/navigation/navigation-pass-data ) :

apply plugin: 'com.android.application'
apply plugin: 'androidx.navigation.safeargs'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'

android {...

I receive this error :

Plugin with id 'androidx.navigation.safeargs' not found.

9 Answers

To add androidx.navigation.safeargsplugin follow below step's

  1. classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha09"
    (latest) Add above to your Project Gradel file inside dependency block

  2. Then add apply plugin: 'androidx.navigation.safeargs' to your app/Module gradle file

Just add this line in your build.gradle project level :

 classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.2.0-rc02"

You can use dependencies as below in Project level bulild.gradle in Android Studio bumblebee

id 'androidx.navigation.safeargs' version '2.4.2' apply false

Add

classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.1.0-alpha05"

In your project-level dependencies

For eg :

dependencies {
       classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.1.0-alpha05"

}

Don't forget to add the latest version

It appears because you are declaring it in the wrong build.gradle file. You have to place it in the build.gradle that looks like this

buildscript {
    repositories {
        google()
    }
    dependencies {
        def nav_version = "2.1.0"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
    }
}

This link explain how it is added https://developer.android.com/jetpack/androidx/releases/navigation#safe_args

In newer version of Android Studio 3.2+, below dependency need to add in both build.gradle file

Project-Level build.gradle

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

App-Level build.gradle

plugins {
    id 'androidx.navigation.safeargs' 
}

I had to add it to the top level build.gradle, not sure if you've just added it to your app level build.gradle instead

I hope this may help others. I followed the directions at developer.android.com and all the instructions here. None of them solved the issue for me. Mine was a simple order of operation in my modules build.gradle file.
I had: id 'androidx.navigation.safeargs.kotlin' listed as the first line in my plugins block.
moving to the end of the block solved my issue

Related