google-developer-training / first-android-app

Repository for Build Your First Android App codelabs (Java and Kotlin)
7 stars 6 forks source link

First Android app codelab: changes to Enable Safe Args #205

Open Tex1976 opened 2 years ago

Tex1976 commented 2 years ago

Describe the problem The code provided to enable Safe Args cannot be used as it is, in the last version of Android Studio.

In which step of the codelab can this issue be found? Task 9 (Implement the second fragment) Step 5 (Enable SafeArgs)

Versions

  1. Android Studio Bumblebee | 2021.1.1 Patch 2
  2. targetSdk 31

Additional information Solution I added the following lines at the beginning of Gradle Scripts > build.gradle (Project: My First App)

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

Then I modified Gradle Scripts > build.gradle (Module: app)

plugins {
    id 'com.android.application'
    id 'androidx.navigation.safeargs'
}

codelab: build-your-first-android-app-java