https://kotlinlang.org logo
Join Slack
Powered by
# stackoverflow
  • r

    rss

    07/27/2025, 12:41 PM
    Duplicate class (guava) in android developement I am getting the error here in this code : plugins { id("com.android.application") id("org.jetbrains.kotlin.android") id("org.jetbrains.kotlin.plugin.parcelize") } android { namespace = "com.example.snapy" compileSdk = 34 defaultConfig { applicationId = "com.example.snapy" minSdk = 24 targetSdk = 34 versionCode = 1 versionName = "1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" }...
  • r

    rss

    07/27/2025, 3:41 PM
    Network API call working locally but not on Apple TestFlight build My Kotlin Multiplatform iOS TestFlight app build has problems reaching some remote apis, but that problem only occurs with the test flight build, not with a local build. Some remote apis work, but the following dont: "api.themoviedb.org" "id.twitch.tv" "accounts.spotify.com" All of them have some kind of authentication, TMDB uses an api key and twitch/spotify use oauth credentials. I'm using BuildKonfig to load my credentials from local.properties into the app. What I tried so far: Add...
  • r

    rss

    07/27/2025, 5:21 PM
    Android AccessibilityService: Can't click button in another app using ACTION_CLICK (isClickable = false) I'm developing an Android accessibility helper app (Kotlin, target SDK 33) that uses AccessibilityService to interact with UI elements in another app (package: ru.imm.app). What I am trying is programmatically click a "send message" button (ID: ru.imm.app:id/imm_message_input_right_outer_icon) in the target app's chat screen. My current approach fails to trigger the click: val node = rootInActiveWindow .findAccessibilityNodeInfosByViewId("ru.imm.app:id/imm_message_input_right_outer_icon")...
  • r

    rss

    07/28/2025, 10:41 AM
    How to fix Checksum Error while doing an Android app's QR Provisioning on a Factory Reset Android? More details: Phone - Vivo Redmi Note 8 Pro Android version - 12 File: app-release.apk Method: QR Provisioning API chosen in Android studio: API 24 Error: ...checksum error. Please contact your IT admin. OS of my PC: Windows 10 Pro So, I was working on an Android app which is basically an EMI locker app: blocks customer's phone via sender phone if they fail to pay their EMI. I divided the process into seperate parts so I can test them efficiently. Now, I am working on QR Provisioning and I...
  • r

    rss

    07/28/2025, 3:31 PM
    Why does Android prohibit running IO-performing coroutines from the main thread? Context and prior understanding: In Node.JS, I/O code is run in a thread pool / event loop parallel to the main JavaScript thread. async code is never truly blocking per-se, unless a blocking call (e.g. fs.*sync functions) are called, which usually shouldn't happen. When the blocking code yields a result, the main loop obtains it from a concurrent queue and runs the continuation. In Rust, async code is usually run in a multi-threaded runtime like tokio. tokio distinguishes two thread pools:...
  • r

    rss

    07/28/2025, 7:31 PM
    How to search both name and code fields simultaneously with Redis OM Spring AutoComplete? I'm using Redis OM Spring with auto-complete functionality and want to search across multiple fields (both name and code) in a single query, rather than making separate calls to each field's auto-complete method. Current Setup Entity: @Document data class AutoSearchStation( @Id @AutoComplete @AutoCompletePayload(fields = ["name", "code"]) var code: String = "", @AutoComplete @AutoCompletePayload(fields = ["name", "code"]) var name: String = "",...
  • r

    rss

    07/28/2025, 8:51 PM
    weblux with retry and circuitBreaker return premature response or error response api-gateway auth request interceptor. That will retry or return default response based on response and response status also modifies response and sends back to client @Configuration class GatewayConfig( private val errorFilter: GlobalErrorFilter, ){ @Bean fun authRequestFilter( builder: RouteLocatorBuilder, ) = builder.routes() .route(authService.name) { r -> r.path(authService.path) .filters { f -> f.retry {...
  • r

    rss

    07/29/2025, 2:51 AM
    Content of exoPlayers overlapping each other I have asked similar question which is unsolved. I am asking again with more information. In my Android app there is a grid view composed of grid items, which can be a video or image. In the followimng grid of 3 items. The first and the 3rd one are videos. The 2nd video's orientation is portrait, and it overflows from its parent container's border into the first video.

    https://i.sstatic.net/9QSUX81K.jpg▾

    I have tried to add all sorts of constraints on...
  • r

    rss

    07/29/2025, 12:11 PM
    Can't create any .jar on IntelliJ Fabric Minecraft modding So lately I've been trying to make a little custom mod for Minecraft 1.21.1 with Fabric Kotlin and after checking everything working completely I wanted to create the .jar to share with a friend but whenever I try to build the artifact, it says the process is done but it doesn't create any new file or if it does I can't seem to find it, I've attached pictures of the settings on Artifact creation and the console to see if anyone can seem to find the error, any ideas would be greatly...
  • r

    rss

    07/29/2025, 12:51 PM
    why is the hilt module not binding the interface and implementation? I have a web layer (LoginWebLayer) calling the api. it is very simple, one method overidden from its interface. @Singleton class LoginWebLayer @Inject constructor( authDataStore: AuthDataStore, environmentProvider: EnvironmentProvider ) : BaseHttpClient( authDataStore = authDataStore, environmentProvider = environmentProvider ), ILoginWebLayer { override suspend fun login( /* method is implemented */) {} /* remaining code omitted */ The web layer has an interface...
  • r

    rss

    07/29/2025, 1:11 PM
    Problems testing kotlin flows I got a personal practice project and i started testing. My problem is about testing flows. In this case i had a repository who fetch data from firebase and Im a bit lost about testing that. private val repositoryScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) private var observerJob: Job? = null override suspend fun stopObservingTasks() { observerJob?.cancel() observerJob = null Timber.d("Repository: Stopped observing tasks") } override...
  • r

    rss

    07/29/2025, 2:11 PM
    SharedPreference.edit().commit() on IO Dispatcher not being received by listeners val sharedPreference = PreferenceManager.getDefaultPreference() val scope = CoroutineScope(Dispatchers.IO) scope.launch { val editor = sharedPreference.edit() editor.putString("stringKey", "stringValue") editor.commit() } Now if a SharedPreferences.OnSharedPreferenceChangeListener is implemented to listen to this like the following, and registered, we do not observe the onSharedPreferenceChanged method being called. class SharedPreferenceChangeListener() :...
  • r

    rss

    07/29/2025, 2:51 PM
    Trying to run a kt_jvm_binary with remotejdk11 but it does not appear in the runfiles at runtime my .bazelversion is 8.3.1 Given this kind of a build file: load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library", "kt_jvm_binary") kt_jvm_binary( name = "my_package", srcs = ["Main.kt"], main_class = "my.package.MainKt", ) And adding these lines to .bazelrc: build --java_runtime_version=remotejdk_11 run --java_runtime_version=remotejdk_11 And this version of rules_kotlin: bazel_dep(name = "rules_kotlin", version = "1.9.1") When I run bazel run //path/to/my_package I get:...
  • r

    rss

    07/29/2025, 3:51 PM
    The artifact `org.jetbrains.kotlin:kotlin-compiler-embeddable` is present in the build classpath along Kotlin Gradle plugin I just upgraded to Kotlin 2.1.20. After clearing countless build errors, I am down to a warning that I get in every module in my app that says this: The artifact org.jetbrains.kotlin:kotlin-compiler-embeddable is present in the build classpath along Kotlin Gradle plugin. This may lead to unpredictable and inconsistent behavior. Please remove the org.jetbrains.kotlin:kotlin-compiler-embeddable artifact from the build classpath. See <a href="https://kotl.in/gradle/internal-compiler-symbols"...
  • r

    rss

    07/30/2025, 3:51 AM
    Decrease Boot Time of Service My android application which is a device owner has a service which starts on BOOT_COMPLETED event to block access to certain apps. However, it takes some time in seconds after loading of UI. Users have few seconds to open the restricted apps. My service should start instantly after start of android/smart TV. Pl suggest how to improve boot time of the service without root.
  • r

    rss

    07/30/2025, 3:31 PM
    Java Desktop#browse fails for specific URI In my Java desktop application I try to launch an URI in the current default browser like this: Desktop.getDesktop().browse(URI(uri)) Normally this works without problems but for the uri string "https://jfspwa.java-forum-stuttgart.de" I only get an exception: Failed to mail or browse https://jfspwa.java-forum-stuttgart.de. Error code: -10827 java.io.IOException: Failed to mail or browse https://jfspwa.java-forum-stuttgart.de. Error code: -10827 at...
  • r

    rss

    07/30/2025, 5:11 PM
    Gradle: why is Android Room not found even though I included the Google Repository? I’m working in a Kotlin project and want to use the Room library for SQlite. So like explained on this site, I added the line id("androidx.room") version "2.7.2" to the plugins section in my build.gradle.kts. As that plugin lives in Google’s Maven repo (as said in the <a href="https://mvnrepository.com/artifact/androidx.room/androidx.room.gradle.plugin/2.7.2" rel="nofollow...
  • r

    rss

    07/30/2025, 5:51 PM
    How do I convert an enum value to camel case on serializing in Micronaut with Jackson? In Micronaut, I want to serialize an enum value as starting with an upper case letter followed by lower case letters. import com.fasterxml.jackson.databind.ObjectMapper import io.micronaut.serde.annotation.Serdeable import io.micronaut.serde.config.naming.UpperCamelCaseStrategy import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test class EnumTest { @Serdeable(naming = UpperCamelCaseStrategy::class) enum class TrafficLight { RED, // my luck in...
  • r

    rss

    07/31/2025, 3:51 AM
    MPAndroidChart real-time plot glitch when updating entries with static viewport and live cursor I am developing a real-time BLE audio application on Android. The audio sampling rate is 16,000 samples per second, and I receive data in 100 packets per second, each packet having 160 samples (so exactly 16kHz). For visualization, I downsample the data from 16kHz to 500Hz, and plot it using MPAndroidChart's LineChart. The chart is configured to be: Static (non-scrollable) Fixed viewport width Reusing Entry objects to optimize performance Shows a "cursor gap" to indicate the current update...
  • r

    rss

    07/31/2025, 7:51 AM
    What's the best game engine to add to an existing jetpack compose project? [closed] So, I'm creating an app with different "tools" (it's more like a sandbox place where I code what I want). Currently, I want to make some mini-games. And, for now, I've used the Canvas component, but in my opinion, it's difficult to handle complex behavior (like collisions). I already tried to use Korge, but I couldn't find a way to integrate it to my existing project (only installing their IDE), and also tried Kubriko, but there is almost no documentation for now. So, do you know a game...
  • r

    rss

    07/31/2025, 3:51 PM
    Proper Implementation of Android Version Catalog I have the dependencies below and I need to use a version catalog. Are the dependencies without quotation marks examples of a version catalog implementation or its that something else? When trying to use version catalog for the import implementation("androidx.navigation:navigation-compose") by doing implementation(androidx.navigation) I get an unresolved reference error. val room_version = "2.3" val billing_version = "8.0.0" dependencies { implementation(libs.androidx.core.ktx)...
  • r

    rss

    07/31/2025, 4:11 PM
    Cloning android Views by copying all properties Since there is no way to clone android views, and inflating a layout is not an option for me, I've been trying to solve this by iterating over and copying all properties. Since there is no way to do that programatically either, it would need to be hardcoded based on a list. I found a list of R.styleable attributes in the View class source code such as *...
  • r

    rss

    07/31/2025, 6:31 PM
    How to make common dropdown for two TextFields in Jetpack Compose? I want to make common dropdown for two TextField. I have manage to do something like following. But there is a problem with focusing. When I click again on the second TextField to open dropdown, it opens the dropdown but focus to first one which I don't want. Is there way to fix this. The Code: data class Dummy( val a: String, val b: String, ) @OptIn(ExperimentalMaterial3Api::class) @Composable fun DoubleTextFieldDropDown( selectedDummy: Dummy?, onSelectedChange: (Dummy?) ->...
  • r

    rss

    08/01/2025, 6:31 AM
    How do I generate a server certificate, that'll work with okhttp 5.1.0 websockets? Trying to wss connect to localhost:6005 (rippled) I've seen workarounds that overrides hostname verification
  • r

    rss

    08/01/2025, 11:11 AM
    Justify Jetpack Compose I have started taking training courses at developer.android.com. I can't figure out why TextAlign.Justify doesn't work. There's my code class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) enableEdgeToEdge() setContent { LearnTogetherTheme { Surface( modifier =...
  • r

    rss

    08/01/2025, 11:31 AM
    Unity + Firebase BOM 34.0.0: NoClassDefFoundError for com.google.firebase.ktx.Firebase despite not using KTX APIs I'm building a Unity 2022.3.47 Android app that uses Firebase Remote Config via native Kotlin code. I recently updated to Firebase BOM 34.0.0, which removes all ktx libraries per Firebase's Kotlin-first migration guide: https://firebase.google.com/docs/android/kotlin-migration Issue The app builds successfully, but crashes at runtime when initializing Remote Config: Exception while initializing...
  • r

    rss

    08/01/2025, 12:51 PM
    Error with Ktor and Exposed with LocalDate field in Postgres (ClassNotFoundException: kotlinx.datetime.Instant) I have a small test table in Postgres with a DATE field, and data class in Ktor app. When mapping the database table row result to TestItem the 'updated' LocalDate field generated the error. import DatabaseFactory.dbQuery import io.ktor.http.HttpHeaders import io.ktor.http.HttpMethod import io.ktor.http.HttpStatusCode import io.ktor.serialization.kotlinx.json.json import io.ktor.server.application.* import io.ktor.server.engine.* import io.ktor.server.netty.* import...
  • r

    rss

    08/01/2025, 1:31 PM
    Android Adapter not always updating data Hello I am having trouble with a problem where on my recycler view it displays sometimes the associated items given in the view. I had this problem earlier and what seem to make it work for the first couple of times was changing it from setImageResource to using setImageDrawable. I think to fix this problem there is something wrong with adapter since I found out by printing the data that was in the list that there was nothing wrong with generateList() function but in the Adapter class...
  • r

    rss

    08/01/2025, 5:51 PM
    Kotlin Bluetooth connection - no up to date tutorial I’ve tried working through the current tutorial for Bluetooth Classic integration. The problem is that nothing works. Some of the methods listed are marked as “deprecated,” then it seems that code is missing in places, but the biggest issue is that I can’t even compile the examples because, since a certain Android version, Bluetooth connections require explicit runtime permission requests—which the tutorial doesn’t mention at all. I’ve scoured the web, but most other tutorials and videos...
  • r

    rss

    08/01/2025, 8:31 PM
    MaterialAlertDialog max height to 90% of screen I want to set MaterialAlertDialog max height yo 90% of the screen so it can be dynamicaly change up to 90% of the screen If i use AlertDialog.Builder->works fine If i use MaterialAlertDialogBuilder ->No