Eine Fehlerquelle Nachrichten stammen aus der Verwendung von SafeArgs und Anweisungen. So zum Beispiel im Code
Code: Select all
NavController navController = Navigation.findNavController(requireActivity(), R.id.navHostfragment);
viewModel.setPastTimeMillis(pastDaysForDisplayingScores);
liveData.forceUpdate();
//Repeat the level if the repeat button is pressed
if (view.getId() == R.id.imageView_RepeatSymbol) {
navController.navigate(DialogFR_LevelEndDirections.actionDialogFRLevelEndToFRGame());
}
Code: Select all
package com.example.game
import androidx.navigation.ActionOnlyNavDirections
import androidx.navigation.NavDirections
public class DialogFR_LevelEndDirections private constructor() {
public companion object {
public fun actionDialogFRLevelEndToFRGame(): NavDirections =
ActionOnlyNavDirections(R.id.action_dialogFR_LevelEnd_to_FR_Game)
public fun actionDialogFRLevelEndToFRMenu(): NavDirections =
ActionOnlyNavDirections(R.id.action_dialogFR_LevelEnd_to_FR_Menu)
}
}
< /code>
so etwas in der Verbindung zwischen den Klassen und den generierten Safeargs funktioniert nicht mehr. Hier sind meine Build.gradle -Datei < /p>
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'androidx.navigation.safeargs.kotlin'
}
android {
namespace 'com.example.game'
compileSdk = 34
defaultConfig {
applicationId "com.example.game"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"
viewBinding {
enabled = true
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.10.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
testImplementation 'junit:junit:4.13.2' // Fixed empty JUnit version
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
implementation platform('com.google.firebase:firebase-bom:32.0.0')
implementation 'com.google.firebase:firebase-database-ktx'
implementation platform("org.jetbrains.kotlin:kotlin-bom:1.8.0")
}
Code: Select all
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.nav_version = '2.7.0' // Use the latest Navigation version
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.1' // Use the latest stable AGP
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
classpath 'com.google.gms:google-services:4.4.0' // Check the latest version
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}