Я обновился до Jetpack Compose 1.0.0-alpha12 и начал сталкиваться с проблемами.
Во-первых, использованный мной метод setContent
был признан устаревшим.
Из примечаний к выпуску Alpha 12 я заметил что он сказал:
ComponentActivity.setContent перемещен в androidx.activity.compose.setContent в модуле androidx.activity: activity-compose. (Icf416)
Поэтому я удалил свой import androidx.compose.ui.platform.setContent
и переключил его на import androidx.activity.compose.setContent
, что устранило устаревание.
Однако затем я получил сообщение об ошибке:
w: Flag is not supported by this version of the compiler: -Xallow-jvm-ir-dependencies
w: ATTENTION!
This build uses unsafe internal compiler arguments:
-XXLanguage:+NonParenthesizedAnnotationsOnFunctionalTypes
This mode is not recommended for production use,
as no stability/compatibility guarantees are given on
compiler or generated code. Use it at your own risk!
e: Classes compiled by an unstable version of the Kotlin compiler were found in dependencies.
Remove them from the classpath or use '-Xallow-unstable-dependencies' to suppress errors
e: /[my path]/MainActivity.kt: (39, 9): Class 'androidx.activity.compose.ComponentActivityKt' is
compiled by an unstable version of the Kotlin compiler and cannot be loaded by this compiler
И снова я смог обойти это, изменив свой build.gradle
файл, чтобы он имел:
kotlinOptions {
jvmTarget = '1.8'
useIR = true
// I added this line
freeCompilerArgs += "-Xallow-unstable-dependencies"
}
Хотя это позволило мне скомпилировать приложение, теперь во время выполнения я получаю следующее исключение:
java.lang.NoSuchMethodError: No static method setContent(
Landroidx/activity/ComponentActivity;Landroidx/compose/runtime/Com
positionContext;Lkotlin/jvm/functions/Function2;)V in class
Landroidx/activity/compose/ComponentActivityKt; or its super classes
(declaration of 'androidx.activity.compose.ComponentActivityKt' appears in [my apk]
Как я могу исправить это и обновить свое приложение до Jetpack Compose 1.0.0-alpha12?