Невозможно импортировать ID ("Kotlin-Parcelize") и навигационные безопасные аргументы в новой версии Android StudioAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Невозможно импортировать ID ("Kotlin-Parcelize") и навигационные безопасные аргументы в новой версии Android Studio

Сообщение Anonymous »

Я только что обновил свою Android Studio до последней версии и начал создавать новый проект, и я сталкиваюсь с проблемами с новейшей системой Android зависимостей
Я попробовал с id ("kotlinparcelize") , затем я изменил его на псевдоним (libs.plugins.kotlin.parzize), и он добавил исправление in libs. Файл
Но я все еще вижу ошибку в моем модельном классе

ps: Is that google google google
ps: Is that google google
ps: i google. />https://issuetracker.google.com/issues/420190924
образнойimport android.net.Uri
import android.os.Parcel
import android.os.Parcelable
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
import androidx.room.TypeConverters
import com.example.domain.utils.UriConverter
import kotlinx.parcelize.Parcelize

@Entity(tableName = "clips_table", indices = [Index(value = ["artistId"])])
@TypeConverters(UriConverter::class)
@Parcelize
data class Clip(
@PrimaryKey val id: Long,
val name: String,
val album: String,
val artist: String,
val albumId: Long,
val artistId: Long,
val duration: Long = 0,
val contentUri: Uri?,
val artUri: Uri?,
var customArtUri: String? = null,
val year: Int? = null,
val dateAdded: Long? = null,
val size: Long? = null,
val genre: String? = null,
val genreId: Long? = null,
val trackNumber: Int? = null,
var isSelected: Boolean = false,
var isFavorite: Boolean = false,
var lastPlayed: Long? = null,
var playCount: Int = 0,
val playlistIds: List = emptyList()
) : Parcelable {

constructor(parcel: Parcel) : this(
parcel.readLong(),
parcel.readString() ?: "",
parcel.readString() ?: "",
parcel.readString() ?: "",
parcel.readLong(),
parcel.readLong(),
parcel.readLong(),
parcel.readTypedObject(Uri.CREATOR),
parcel.readTypedObject(Uri.CREATOR),
parcel.readString(),
parcel.readInt().takeIf { it != 0 },
parcel.readLong().takeIf { it != 0L },
parcel.readLong().takeIf { it != 0L },
parcel.readString(),
parcel.readLong(),
parcel.readInt().takeIf { it != Int.MIN_VALUE },
parcel.readInt() == 1,
parcel.readInt() == 1,
parcel.readLong().takeIf { it != 0L },
parcel.readInt(),
parcel.createLongArray()?.toList() ?: emptyList()
)

override fun describeContents(): Int = 0

override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeLong(id)
dest.writeString(name)
dest.writeString(album)
dest.writeString(artist)
dest.writeLong(albumId)
dest.writeLong(artistId)
dest.writeLong(duration)
dest.writeParcelable(contentUri, flags)
dest.writeParcelable(artUri, flags)
dest.writeString(customArtUri)
dest.writeInt(year ?: 0)
dest.writeLong(dateAdded ?: 0L)
dest.writeLong(size ?: 0L)
dest.writeString(genre)
dest.writeLong(genreId ?: 0L)
dest.writeInt(trackNumber ?: Int.MIN_VALUE)
dest.writeInt(if (isSelected) 1 else 0)
dest.writeInt(if (isFavorite) 1 else 0)
dest.writeLong(lastPlayed ?: 0L)
dest.writeInt(playCount)
dest.writeLongArray(playlistIds.toLongArray())
}

companion object CREATOR : Parcelable.Creator {
override fun createFromParcel(parcel: Parcel): Clip {
return Clip(parcel)
}

override fun newArray(size: Int): Array {
return arrayOfNulls(size)
}
}
}

build.gradle (project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.dagger.hilt.plugin) apply false
alias(libs.plugins.kotlin.kapt) apply false
alias(libs.plugins.ksp) apply false
// alias(libs.plugins.navigation.safe.args) apply false
alias(libs.plugins.kotlin.parcelize) apply false
// id("androidx.navigation.safeargs.kotlin")
// id("org.jetbrains.kotlin.plugin.parcelize") version libs.versions.kotlin apply false

}

buildscript {

dependencies {

classpath ("androidx.navigation:navigation-safe-args-gradle-plugin:2.8.9")

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

Плагин правильно настроен в libs.versions.toml file
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
android-library = { id = "com.android.library", version.ref = "agp" }
dagger-hilt-plugin = { id = "com.google.dagger.hilt.android", version.ref = "hiltVersion" }
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kapt-version" }
ksp = { id = "com.google.devtools.ksp", version = '2.1.21-2.0.1' }
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }

build.gradle.kts (app)
plugins {
alias(libs.plugins.kotlin.android)
alias(libs.plugins.android.application)
alias(libs.plugins.dagger.hilt.plugin)
alias(libs.plugins.kotlin.kapt)
// alias(libs.plugins.navigation.safe.args)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.ksp)
// id("kotlin-parcelize")

}

android {
namespace = "com.example.mmlaudioplayer"
compileSdk = 36

defaultConfig {
applicationId = "com.example.mmlaudioplayer"
minSdk = 24
targetSdk = 36
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildFeatures {
viewBinding = true
android.buildFeatures.buildConfig = true
buildConfig = true
}

buildTypes {
debug {
isDebuggable = true
buildConfigField("boolean", "IS_DEBUG_MODE", "true")

}
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
buildConfigField("boolean", "IS_DEBUG_MODE", "false")
}
}
hilt {
enableAggregatingTask = true
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.material) {
exclude(group = "androidx.recyclerview", module = "recyclerview")
exclude(group = "androidx.recyclerview", module = "recyclerview-selection")
}

// تطبيق RecyclerView و Selection بشكل صريح
implementation(libs.androidx.recyclerview)
// implementation(libs.androidx.recyclerview.selection)

implementation(libs.androidx.activity)
implementation(libs.androidx.constraintlayout)
implementation(libs.coroutines)

// implementation(libs.dagger.hilt)
// ksp(libs.dagger.hilt.compiler)

implementation(libs.dagger.hilt)
implementation(libs.androidx.navigation.fragment.ktx)
// implementation(libs.androidx.navigation.ui.ktx)
ksp(libs.dagger.hilt.compiler)
implementation(libs.play.review)
implementation(libs.play.review.ktx)
implementation(libs.shimmerAnimation)

implementation(libs.androidx.viewmodel)
implementation(libs.androidx.livedata)
implementation(libs.androidx.lifecycle)
implementation(libs.androidx.media)
implementation(libs.room.runtime)
implementation(libs.room.ktx)
ksp(libs.room.compiler)

implementation(libs.sdp)
implementation(libs.ssp)

implementation(libs.glide)
ksp(libs.glide.compiler)

implementation(libs.androidx.palette)
implementation(libs.androidx.swiperefreshlayout)

testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)

implementation(project(":domain"))
implementation(project(":data"))
}
< /code>
версия IDE < /p>
Android Studio Narwhal | 2025.1.1 Patch 1
Build #AI-251.25410.109.2511.13752376, built on July 9, 2025
Runtime version: 21.0.6+-13391695-b895.109 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.awt.windows.WToolkit
Windows 11.0
Kotlin plugin: K2 mode
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 4096M
Cores: 28
Registry:
ide.instant.shutdown=false
ide.experimental.ui=true
com.android.studio.ml.activeModel=com.android.studio.ml.AidaModel
Non-Bundled Plugins:
wu.seal.tool.jsontokotlin (3.7.7)
com.gionchat.json.bean (1.0.5)
com.robohorse.robopojogenerator (2.6.3)
com.thoughtworks.gauge (251.25410.129)


Подробнее здесь: https://stackoverflow.com/questions/795 ... ew-android
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»