I'm trying to add safeargs to my project, but it doesn't let me do so. I have tried every solution, yet still not working. I have tried to change the versions, even the actual navigation classpath and the plugin but nothing seems to work.
Gradle project:
buildscript {
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
}
dependencies {
def navigationVersion = "2.3.5"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigationVersion"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Gradle app: plugins { id 'com.android.application' id 'kotlin-android' id 'kotlin-android-extensions' id 'kotlin-kapt' apply plugin: 'androidx.navigation.safeargs'
}
android {
namespace 'com.example.planner'
compileSdk 33
defaultConfig {
applicationId "com.example.planner"
minSdk 25
targetSdk 33
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 {
viewBinding true
dataBinding true
}
}
dependencies {
implementation 'com.google.android.material:material:1.8.0-beta01'
implementation("androidx.compose.material3:material3:1.0.1")
implementation("androidx.compose.material3:material3-window-size-class:1.0.1")
// Room components
implementation "androidx.room:room-runtime:2.4.3"
kapt "androidx.room:room-compiler:2.4.3"
implementation "androidx.room:room-ktx:2.4.3"
androidTestImplementation "androidx.room:room-testing:2.4.3"
// Kotlin components
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.20"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
// Lifecycle components
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation "androidx.lifecycle:lifecycle-common-java8:2.5.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
// Navigation Component
val nav_version = "2.5.3"
implementation("androidx.navigation:navigation-fragment-ktx:2.5.3")
implementation("androidx.navigation:navigation-ui-ktx:2.5.3")
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.20"
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
}
CodePudding user response:
In your build.gradle(project)
, add this
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
id 'androidx.navigation.safeargs.kotlin' version '2.5.3' apply false
}
In your build.gradle(app)
, add this
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'androidx.navigation.safeargs.kotlin'
id 'kotlin-parcelize'
}
Try with these plugins, it works for me. If not for you, let me know