Вот MainActivity из модуля приложения:
Код: Выделить всё
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MyApplicationTheme {
// A surface container using the 'background' color from the theme
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
Column(modifier = Modifier.fillMaxSize()) {
Greeting("Android")
secondScreen.Asnackbar()
}
}
}
}
}
}
@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
Text(
text = "Hello $name!",
modifier = modifier
)
}
Код: Выделить всё
import androidx.compose.material3.Snackbar
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
@Composable
fun Asnackbar(){
Snackbar {
Text("this is a snackbar")
}
}
Код: Выделить всё
java.lang.NoSuchMethodError: No virtual method Asnackbar(Landroidx/compose/runtime/Composer;I)V in class Lcom/example/second_screen/SecondScreen; or its super classes (declaration of 'com.example.second_screen.SecondScreen' appears in /data/data/com.example.myapplication/code_cache/.overlay/base.apk/classes2.dex)Поэтому все, что мне нужно сделать, это добавить эти строки в мой модуль второго экрана:
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.5.1'
Подробнее здесь: https://stackoverflow.com/questions/771 ... inactivity
Мобильная версия