Home > Enterprise >  I'm trying to use safe args but when i add the dependencies to the project level build.gradle i
I'm trying to use safe args but when i add the dependencies to the project level build.gradle i

Time:08-02

plugins {
   id 'com.android.application' version '7.2.1' apply false
   id 'com.android.library' version '7.2.1' apply false
   id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
}
dependencies {
   "android.arch.navigation:navigation-safe-args-gradle-plugin:$version_navigation"
}

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

Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'version_navigation' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

CodePudding user response:

Add these line in dependencies block:

        val nav_version = "2.5.1"
        classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.5.1")

if you want use another version so change in 2.5.1

CodePudding user response:

On project build.gradle (Top-level build file):

just add buildscript on top of the file. plugins and task clean depends on your project

buildscript {
  repositories {
    google()
  }
  dependencies {
    classpath("androidx.navigation:navigation-safe-args-gradle plugin:2.5.1")
  }
}

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

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

Module build.gradle:

if u use kotlin add next line into plugins:

id "androidx.navigation.safeargs.kotlin"

if java add next line into plugins

id "androidx.navigation.safeargs"

add next line into gradle.properties:

line might exist but in false

android.useAndroidX=true
  • Related