Проблема с Animatore после обновления проектаAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Проблема с Animatore после обновления проекта

Сообщение Anonymous »

У меня есть старый проект 2023-2024 года, и я решил обновить все зависимости, gradle и agp, но после исправления ошибки gradle («targetjvm устарел») мое приложение тормозит после нажатия на кнопки или что-то в этом роде с помощью onclick (кажется так, потому что с текстовыми полями все в порядке) я получаю следующий журнал краша:

Код: Выделить всё

java.lang.IllegalStateException: Cannot start this animator on a detached view!
at android.graphics.RenderNode.addAnimator(RenderNode.java:1659)
at android.graphics.animation.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:288)
at android.graphics.animation.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:277)
at android.graphics.drawable.RippleForeground.startPending(RippleForeground.java:139)
at android.graphics.drawable.RippleForeground.drawHardware(RippleForeground.java:168)
at android.graphics.drawable.RippleForeground.draw(RippleForeground.java:340)
at android.graphics.drawable.RippleDrawable.drawBackgroundAndRipples(RippleDrawable.java:1238)
at android.graphics.drawable.RippleDrawable.drawSolid(RippleDrawable.java:860)
at android.graphics.drawable.RippleDrawable.draw(RippleDrawable.java:842)
at android.view.View.drawBackground(View.java:26627)
at android.view.View.draw(View.java:26334)
at androidx.compose.material.ripple.RippleHostView.draw(RippleHostView.android.kt:62)
at androidx.compose.material.ripple.AndroidRippleNode.drawRipples(Ripple.android.kt:147)
at androidx.compose.material.ripple.RippleNode.draw(Ripple.kt:391)
at androidx.compose.ui.node.LayoutNodeDrawScope.drawDirect-eZhPAX0$ui(LayoutNodeDrawScope.kt:132)
at androidx.compose.ui.node.LayoutNodeDrawScope.draw-eZhPAX0$ui(LayoutNodeDrawScope.kt:119)
at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:484)
at androidx.compose.ui.node.NodeCoordinator.access$drawContainedDrawModifiers(NodeCoordinator.kt:69)
Информация о проекте

Код: Выделить всё

jvmtarget = java 1.8
kotlinVersion = 2.3.10
composeBomVersion = 2026.02.01
activityComposeVersion = 1.12.4
material3={module="androidx.compose.material3:material3"}
модуль gradle.kts

Код: Выделить всё

import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.google.services)
alias(libs.plugins.firebase.crashlytics)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.compose.compiler)

}

tasks.withType().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
}
android {
namespace = ...
compileSdk = 36

defaultConfig {
applicationId = ...
minSdk = 26
targetSdk = 34
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
//  "jvmTarget" string is deprecated
//    kotlinOptions {
//        jvmTarget = "1.8"
//        // use "-PenableComposeCompilerReports=true"  to enable
//        if ((project.findProperty("enableComposeCompilerReports") as? String).toBoolean()) {
//            val outputDir = project.layout.buildDirectory.dir("compose-reports").get()
//            freeCompilerArgs = freeCompilerArgs + listOf(
//                "-P",
//                "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=$outputDir",
//                "-P",
//                "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=$outputDir"
//            )
//        }
//    }
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.10"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

dependencies {
//was added to fix crashes but didnt help
implementation("androidx.compose.animation:animation:1.10.4")
implementation("androidx.compose.animation:animation-graphics:1.10.4")
//splashScreen
implementation(libs.splashscreen)

implementation(libs.exifinterface)
implementation(libs.androidx.material.icons.core)

//Unit tests
testImplementation(libs.kotlinx.coroutines.test)
// Import the BoM for the Firebase platform
implementation(platform(libs.firebase.bom))

implementation(libs.firebase.analytics)
implementation(libs.firebase.crashlytics)
implementation(libs.firebase.messaging)
implementation(libs.firebase.messaging.directboot)

//view models navigation coil
implementation(libs.lifecycle.viewmodel.compose)
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.androidx.runtime.livedata)
implementation(libs.androidx.navigation.compose)
implementation(libs.kotlinx.serialization.json)
implementation(libs.androidx.datastore.preferences.android)
implementation(libs.coil.compose)

//Ktor
implementation(libs.ktor.client.core)
implementation(libs.ktor.client.android)
implementation(libs.ktor.client.json)
implementation(libs.ktor.serialization.kotlinx.json)
implementation(libs.ktor.client.content.negotiation)
implementation(libs.ktor.client.logging)

//default
implementation(libs.core.ktx)
implementation(libs.lifecycle.runtime.ktx)
implementation(libs.activity.compose)
implementation(platform(libs.compose.bom))
implementation(libs.ui)
implementation(libs.ui.graphics)
implementation(libs.ui.tooling.preview)
implementation(libs.material3)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.compose.bom))
androidTestImplementation(libs.ui.test.junit4)
debugImplementation(libs.ui.tooling)
debugImplementation(libs.ui.test.manifest)
}

Код: Выделить всё

[versions]
animationVersion = "1.10.4"
coilComposeVersion = "2.7.0"
composeBomVersion = "2026.02.01"
activityComposeVersion = "1.10.0"
coreKtxVersion = "1.17.0"
datastorePreferencesAndroidVersion = "1.2.0"
espressoCoreVersion = "3.7.0"
firebaseBomVersion = "34.10.0"
firebaseMessagingDirectbootVersion = "25.0.1"
foundationVersion = "1.10.4"
junit = "1.3.0"
junitVersion = "4.13.2"
kotlinxCoroutinesTestVersion = "1.10.2"
kotlinxSerializationJsonVersion = "1.10.0"
ktorVersion = "3.4.1"
lifecycleRuntimeKtxVersion = "2.10.0"
navigationComposeVersion = "2.9.7"
runtimeLivedataVersion = "1.10.4"
androidGradlePlugin= "8.13.2"
kotlinVersion="2.3.10"
googleServices="4.4.4"
firebaseCrashlytics="3.0.6"
kotlinSerialize="2.3.10"
exifinterfaceVersion = "1.4.2"
splashScreenVersion="1.2.0"
materialIconsCoreVersion = "1.7.8"

[libraries]
#SplashScreen
androidx-animation = { module = "androidx.compose.animation:animation", version.ref = "animationVersion" }
androidx-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "foundationVersion"  }
androidx-animation-graphics = { module = "androidx.compose.animation:animation-graphics", version.ref = "animationVersion" }
firebase-messaging-directboot = { module = "com.google.firebase:firebase-messaging-directboot", version.ref = "firebaseMessagingDirectbootVersion" }
splashscreen = {module="androidx.core:core-splashscreen", version.ref="splashScreenVersion"}

exifinterface = {module="androidx.exifinterface:exifinterface", version.ref="exifinterfaceVersion"}

#unit test coroutines//????
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinxCoroutinesTestVersion" }

#firebase
firebase-bom = { module = "com.google.firebase:firebase-bom", version.ref = "firebaseBomVersion" }

firebase-analytics = {module = "com.google.firebase:firebase-analytics", version = "23.0.0" }
firebase-crashlytics = {module = "com.google.firebase:firebase-crashlytics", version = "20.0.4" }
firebase-messaging = {module = "com.google.firebase:firebase-messaging"}

#viewmodels navigation coil
lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycleRuntimeKtxVersion" }
androidx-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "lifecycleRuntimeKtxVersion" }
androidx-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata", version.ref = "runtimeLivedataVersion" }
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigationComposeVersion" }
#??
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJsonVersion" }
androidx-datastore-preferences-android = { module = "androidx.datastore:datastore-preferences-android", version.ref = "datastorePreferencesAndroidVersion" }
#??
coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coilComposeVersion" }

#ktor
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktorVersion" }
ktor-client-android = { module = "io.ktor:ktor-client-android", version.ref = "ktorVersion" }
ktor-client-json = { module = "io.ktor:ktor-client-json", version.ref = "ktorVersion" }
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktorVersion" }
ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktorVersion" }
ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktorVersion" }

#default
core-ktx = { module = "androidx.core:core-ktx", version.ref = "coreKtxVersion" }
lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtxVersion" }
activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityComposeVersion" }
compose-bom = { module = "androidx.compose:compose-bom", version.ref = "composeBomVersion" }
ui={module="androidx.compose.ui:ui"}
ui-graphics={module="androidx.compose.ui:ui-graphics"}
ui-tooling-preview={module="androidx.compose.ui:ui-tooling-preview"}
material3={module="androidx.compose.material3:material3"}
junit = { module = "junit:junit", version.ref = "junitVersion" }
androidx-junit = { module = "androidx.test.ext:junit", version.ref = "junit" }
androidx-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espressoCoreVersion" }
ui-test-junit4={module="androidx.compose.ui:ui-test-junit4"}
ui-tooling={module="androidx.compose.ui:ui-tooling"}
ui-test-manifest={module="androidx.compose.ui:ui-test-manifest", version = "1.6.3" }
androidx-material-icons-core = { group = "androidx.compose.material", name = "material-icons-core", version.ref = "materialIconsCoreVersion" }

[plugins]
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin"  }
android-library = {id="com.android.library", version.ref="androidGradlePlugin"}
kotlin-android = {id="org.jetbrains.kotlin.android", version.ref="kotlinVersion"}

compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlinVersion" }
google-services = {id="com.google.gms.google-services", version.ref="googleServices"}

firebase-crashlytics = {id="com.google.firebase.crashlytics", version.ref="firebaseCrashlytics"}

kotlin-serialization = {id="org.jetbrains.kotlin.plugin.serialization", version.ref="kotlinSerialize"}
!!!!Чтобы повторить краш нужна даже простая кнопка без настраиваемой анимации, при нажатии текст пропадает и раздавливается


Подробнее здесь: https://stackoverflow.com/questions/799 ... ng-project
Ответить

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

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

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

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

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