https://kotlinlang.org logo
Join Slack
Powered by
# android
  • k

    keo kawasaki

    07/13/2025, 7:10 PM
    I am trying to create a keyboard. that requires me to impl InputMethodService(), and LifecycleOwner. But my app crashes when i try to open the keyboard on my phone with an exception saying
    ViewTreeLifecycleOwner not found
    the log statement shows that
    this
    is indeed the viewtree lifecycleowner ps. this is my first time using kotlin and developing android apps, but not new to programming
    not kotlin but kotlin colored 3
    c
    e
    • 3
    • 2
  • b

    Bitter

    07/14/2025, 10:42 AM
    Folks . In compose LazyVerticalGrid using GridCells.Adaptive , isn't the left over space distributed evenly ? For example , lets assume I have
    Copy code
    GridCells.Adaptive(100.dp)
    and I am runnin the app which has the screen width of 350.dp . The compiler would identify that I can draw 3 columns , and 50dp would be left over . What would happen to the left over space ? I am unable to utilize the left over space evenly despite horizontalArrangement .
    Copy code
    LazyVerticalGrid(
        modifier = Modifier.fillMaxWidth().background(Color.Blue),
        horizontalArrangement = Arrangement.SpaceBetween,
        columns = GridCells.Adaptive(100.dp)
    ) {
        items(items) { room ->
            RoomItem(room)
        }
    }
    
    @Composable
    fun RoomItem(room: RoomView) {
        Box(
            Modifier
                .fillMaxWidth() // Fills the width of the column
                .height(120.dp) // Give it a fixed height for visual clarity
                .background(Color.Green) // This is the column's actual area
                .padding(4.dp), // Some padding for visual separation
            contentAlignment = Alignment.Center
        ) {
           
            Text(text = "Room: ${room.name}", color = Color.White) // Just a placeholder
        }
    
    
    }
    The code above yields the result in the screenshot. All my items are stacked after each other and the remaining space just appears at the end .
    c
    • 2
    • 2
  • n

    Nicolai

    07/16/2025, 9:03 PM
    Hi, not entirely sure if this is the right channel—please feel free to redirect me if needed. Unfortunately, I can’t share the full codebase due to confidentiality, but I’m hoping someone can help point me in the right direction or offer any insight. I’m working with Jetpack Compose and have a composable that contains a
    HorizontalPager
    with
    beyondViewportPageCount = 0
    , hosting 5 tabs. Each tab is backed by its own
    ViewModel
    , as they require separate API calls to fetch different sets of data. Some tabs trigger multiple calls, and a few have refresh timers that periodically update their data. Functionally, everything mostly works. However, after navigating into a tab, selecting an item, returning, and repeating this process a few times, I encounter a crash. The issue is that there’s no meaningful stack trace—just an abrupt crash, which makes it hard to trace the root cause. I suspect this may be related to a memory issue—perhaps due to multiple ViewModels, background tasks, or improper cleanup when navigating in and out. I’ve attempted various optimizations, but I’m concerned I might be missing something fundamental, especially in the context of using
    HorizontalPager
    with multiple dynamic ViewModels and background activity. Any advice, debugging tips, or even things to watch out for in this setup would be greatly appreciated. (Will add Logcat below in thread.)
    s
    g
    • 3
    • 4
  • r

    Reyst

    07/21/2025, 10:39 AM
    Hi. I have a Room DB and DAO, which return flow. Dao function accepts as a parameter ID of the Route-object. The ViewModel contains a StateFlow with the current route. Task is: 1. At current route changes must be updated parameters of DB-observing 2. At DB changes must be updated UI I've tried next construction, but it is not working, i don't receive DB-updates
    Copy code
    val routeStatusFlow = coordinator.sharedState
            .map { it.currentRoute }
            .distinctUntilChanged()
            .flatMapLatest {
                if (it != null) {
                    combine(
                        tasksRepository.getTasksSummaryFlow(it.id, START_IDENT),
                        tasksRepository.getTasksSummaryFlow(it.id, END_IDENT),
                    ) { start, end -> RouteStatusViewState(it.status, start, end) }
                } else flowOf(RouteStatusViewState())
            }
            .stateIn(
                scope = viewModelScope,
                started = SharingStarted.WhileSubscribed(LIFECYCLE_TIMEOUT_MS),
                initialValue = RouteStatusViewState(),
            )
    What an I doing wrong?
    not kotlin but kotlin colored 2
    c
    n
    • 3
    • 4
  • d

    David

    07/22/2025, 12:10 PM
    Anyone gotten
    when guards
    to work in Android Studio w/o warnigns? I'm running kotlin
    2.2.0
    and using latest stable Android Studio, also tested latest Canary, but still get warning about it being an experimental feature:
    Copy code
    The feature "when guards" is experimental and should be enabled explicitly. This can be done by supplying the compiler argument '-Xwhen-guards', but note that no stability guarantees are provided.
    Building from command line and android studio works fine, however android studio still gives off warning. I have K2 mode enabled in Android Studio.
    n
    • 2
    • 6
  • u

    Umit AYDIN

    07/23/2025, 8:35 AM
    Are Kotlin Rich Errors available in 2.2.0 as experimental?
    f
    d
    +2
    • 5
    • 6
  • a

    Aleksandar Ilic

    07/24/2025, 2:21 PM
    Hey folks! Did anyone had an issue with their Compose app flickering on tablets in landscape mode? Some users also reported flickering on Pixel 9 Pro Fold, but with emulators it flickers only on Pixel Large Tablet. I’m posting a video in a thread.
    p
    d
    +2
    • 5
    • 16
  • i

    igor.wojda

    07/28/2025, 7:45 AM
    Hi 👋 I am Looking for examples of well-structured, modern open source Android projects to learn from. Any recommendations for projects that showcase best practices, libs, Gradle plugins, and architecture?
    not kotlin but kotlin colored 2
    c
    m
    +2
    • 5
    • 4
  • k

    K Merle

    07/29/2025, 6:27 AM
    Anyone else updated the target SDK on store to 35, but message didn't disappear?
    Copy code
    Update your target API level by 31 August 2025 to release updates to your app
    We've detected that your app is targeting an old version of Android. To provide users with a safe and secure experience, Google Play requires all apps to meet target API level requirements.
    
    From 31 August 2025, if your target API level is not within one year of the latest Android release, you won't be able to update your app.
    not kotlin but kotlin colored 2
    c
    f
    y
    • 4
    • 8
  • c

    calidion

    07/30/2025, 3:17 AM
    Is there any simple webrtc based text messaging android example in kotlin?
  • u

    ursus

    07/31/2025, 12:54 AM
    Copy code
    Task :app:l8DexDesugarLibRelease
    Info: Unexpected error while reading io.ktor.client.plugins.api.HookHandler's kotlin.Metadata: element 'k' is missing.
    Info: Unexpected error while reading kotlinx.coroutines.channels.BufferedChannelKt's kotlin.Metadata: element 'k' is missing.
    .. milions of these
    anyone seeing these in new AGP?
  • b

    Bernhard

    07/31/2025, 11:30 AM
    hi, I've done a lot of server-side (Spring) and client-side (Kotlin JS) development with Kotlin and am looking into getting into Android; what am I looking for? KMP with jetpack compose?
    ✅ 1
    g
    j
    +2
    • 5
    • 9
  • s

    SuneelDev

    08/01/2025, 9:55 AM
    A few days ago I got this message Native libraries (.so files) must have their LOAD segments aligned to 16 KB boundaries. My apk app-debug. Apk is not compatible with 16kb device. So can you help me with figers out
    not kotlin but kotlin colored 2
    d
    c
    • 3
    • 7
  • a

    Arun Sudharsan

    08/02/2025, 7:04 PM
    Hi everyone 👋 - not sure if this is the right channel, please feel free to redirect me if there’s a better one. I recently raised a patch that reduced our APK size by ~350KB, and I’d like some feedback on the safety of the change and better ways to validate it. Change details • Problem: Kotlin generates internal null-safety checks and assertions (
    kotlin.jvm.internal.Intrinsics
    calls). These account for ~2% of our APK size. • Solution: Added ProGuard
    -assumenosideeffects
    rules to remove these internal assertion methods (
    checkNotNull
    ,
    checkParameterIsNotNull
    , etc.). • Effect: Functionality remains the same; only runtime safety checks are stripped out. • Trade-offs (which we’re okay with): ◦ Crash stack traces may lose some detail ◦ Some Kotlin-generated safety information from
    Intrinsics.java
    will be missing Project context • Codebase: ~97% Kotlin, ~3% Java (20+ files). Concerns • Kotlin → Kotlin calls: Should be safe since nullability contracts are enforced at compile time. • Java → Kotlin calls: Potential risk, since a Kotlin method expecting non-null could be called with a nullable from Java. Current approach • We’re reviewing and testing all Java → Kotlin call sites. • Running automation suite + manual QA for validation. My questions 1. How safe is this approach in practice? Are there pitfalls we might be missing? 2. Is there a more automated / systematic way (beyond manual inspection + tests) to gain confidence that removing these null-safety checks won’t cause issues in production? Would love to hear if anyone has tackled this before, or has suggestions for tooling / strategies to improve our conviction here. 🙏
    p
    e
    • 3
    • 5
  • c

    Can

    08/04/2025, 9:55 AM
    Hello everyone, I'm using the Auth0 JWT library to communicate with an API. Everything works fine on the emulator (I'm currently logging in), but when I try to log in with a physical device, I get this error: "Cannot handle token with iat prior to 2025-08-04T124445+0300". As far as I understand, this problem is caused by the following part of my code: "val issuedAt = System.currentTimeMillis() val expiresAt = issuedAt + 300 * 1000" How can I solve this?
    not kotlin but kotlin colored 4
    google 2
    stackoverflow 3
    c
    j
    e
    • 4
    • 5
  • t

    Tobias Preuss

    08/07/2025, 9:59 PM
    Android 15 / edge-to-edge / window insets / legacy 😵 supportActionBar I am dealing with an
    Activity
    (with
    supportActionBar
    , no XML toolbar) and its nested
    Fragment
    (with the toolbar icons setup via
    MenuProvider
    ,
    onCreateMenu
    ,
    onMenuItemSelected
    ). The actual content view is in Compose >
    Scaffold
    but without a
    TopBar
    ! I am trying to enable edge-to-edge and to extend the
    supportActionBar
    to the statusBar. Is there an API? I tried
    enableEdgeToEdge
    ,
    fitsSystemWindows
    on the Toolbar style and via
    window.decorView
    . No success though.
    not kotlin but kotlin colored 4
    google 2
    c
    • 2
    • 1
  • g

    Giang Vu Truong

    08/08/2025, 2:51 AM
    Hello team, hello mina san, I study android jetpack compose. I use Kotlin '1.9.0 -> 2.0.21' version and Kapt (for the Room and the Hilt) . However , I am conflited the between the Kotlin and the Kapt. I see happen this error 'Execution failed for task 'appkaptDebugKotlin'.' Who help me , please? ( I try with AI such as Git Copilot , Chat GPT, ... but don't effective.)
    build.gradle.ktslibs.versions.toml
    c
    • 2
    • 1
  • y

    yash rathor

    08/09/2025, 8:15 PM
    👋 Hello, team!
    ✋ 3
    not kotlin but kotlin colored 1
    🤦‍♂️ 1
  • y

    yousef shaaban

    08/10/2025, 9:19 AM
    Hello everyone i face an issue android 15 how to make screen as full screen but i need Component don't overlap bars of content of the screen
    not kotlin but kotlin colored 3
    c
    a
    • 3
    • 4
  • s

    Slackbot

    08/10/2025, 1:17 PM
    This message was deleted.
    p
    • 2
    • 2
  • m

    Mau NG

    08/11/2025, 7:19 AM
    👋 Hola, equipo.
    not kotlin but kotlin colored 2
    🤦‍♂️ 1
  • e

    Eugene Maksymenko

    08/12/2025, 10:08 AM
    Powerful optimization of the first KMP 3D Globe engine WorldWind Kotlin v1.8.2 released https://github.com/WorldWindEarth/WorldWindKotlin/releases/tag/v1.8.2
    🚫 2
    🔥 3
    c
    • 2
    • 2
  • t

    Tanmay Shree

    08/12/2025, 4:06 PM
    Hi everyone, I'm trying to implement FCM notifications on Android, but I want to open a particular screen based on the type of notification, I am sending a
    context
    parameter in the data block in fcm request but unable to get it in the MainActivity when I click on the notification.
    not kotlin but kotlin colored 5
    c
    • 2
    • 1
  • a

    Abhimanyu

    08/13/2025, 9:02 AM
    Hi all 👋 , In this talk by Arkadii Ivanov about Kotlin Library compatibility -

    https://youtu.be/dI07ZvnwZgE?si=4DAW9GLItbe-rIuM▾

    . It is mentioned that a method changing to synthetic is ABI compatible. Could anyone please help share some resources about this?
    e
    • 2
    • 1
  • s

    Slackbot

    08/13/2025, 10:06 PM
    This message was deleted.
    u
    • 2
    • 1
  • c

    Can

    08/14/2025, 12:15 PM
    Hi guys, i need to create data table in my kotlin project. I can't find any guidance in material design docs. I couldn't find any useful libraries. Do you have any recommendations?
    not kotlin but kotlin colored 3
    c
    m
    • 3
    • 3
  • b

    Barry Fawthrop

    08/16/2025, 6:20 PM
    I have an APK that the analyze says passes 16KB all has yes, none have an issue. Yet when installing on an emulator it gives the ELF 16 KB warning, Any advice?
    not kotlin but kotlin colored 2
    c
    f
    • 3
    • 2
  • o

    Oliver.O

    08/20/2025, 9:08 PM
    Questions for everyone interested in improving Kotlin+Android testing (from the author of TestBalloon, a new Kotlin test framework): If you weren't tied to JUnit 4, how would you like to write Kotlin+Android tests (local, instrumented, Compose, ...)? What are you missing? What's good the way it is? All ideas welcome! 🧵Please.
    ❤️ 1
    👍 1
    t
    g
    d
    • 4
    • 23
  • a

    azeddine

    08/22/2025, 1:53 PM
    👋 Bonjour tout le monde !
    🙌 4
    c
    • 2
    • 1
  • p

    prasanna

    08/25/2025, 8:29 AM
    I am currently building the project in kotlin +XML is this good or I want to move to the jetcompose guide me guys
    p
    g
    t
    • 4
    • 6