https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
stackoverflow
  • u

    user

    06/28/2022, 5:31 PM
    ScriptEngine reusing arguments? I've been running into weird issues with Kotlins JSR-223 implementation for ScriptEngine (kotlin-scripting-jsr223) Basically, i have a condition, which i parse and compile into a CompiledScript: fun parse(clazz: KClass, condition: String): String { val simpleName = clazz.simpleName return """ import ${clazz.java.name} val condition: $simpleName.() -> Boolean = { ${trimQuotes(condition)} } fun check(event: $simpleName) =...
  • u

    user

    06/28/2022, 5:51 PM
    groovy.lang.MissingPropertyException: Could not set unknown property 'useIR' for object of type org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptionsImpl i cloned kickstarter from github & facing this error kotlinOptions { jvmTarget = JavaVersion.VERSION_11.toString() useIR = true } i have tried rebuilding , cleaning project but cant resolve this issue & there are no similar issues i found out there A problem occurred evaluating project ':app'. Could not set unknown property 'useIR' for object of type org.jetbrains.kotlin.gradle.dsl.KotlinJvmOption // Copy google-services.json from variant directory to root of app...
  • u

    user

    06/28/2022, 6:11 PM
    MockK Kotlin: Verification failed: call 1 of 1: was not called I'm trying to essentially test whether a specific method in my class calls a different method properly. I'll remove all unneeded code, so basically my code is as follows: public class Monitor { protected void onMessage(String message) { Log.d(TAG, "Detected the message") changeOptions(); } protected void changeOptions() { Log.d("Reached changeOptions() method"); } } RunWith(RobolectricTestRunner::class) class MonitorTest { private lateinit var mymonitor :...
  • u

    user

    06/28/2022, 6:31 PM
    Removing underline in hyperlink Android Studio Relatively new to the whole Android Studio world - building my first app (self-taught). After hours of search not only Stack, but Google, I cannot find a suitable answer to the below. All answers that I can see are a little more advanced to understand. I have a TextView on my 'settings' activity: I have defined my URL on string. Submit a review On my settings.kt page I have the following code onCreate: ''' val mTextView =...
  • u

    user

    06/28/2022, 7:11 PM
    Having difficulty understanding layoutinflater Android Studio (Kotlin) I am aware of a post that was made before this pertaining to the same topic, however it was in java. override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { // create a new view val adapterLayout = LayoutInflater.from(parent.context) .inflate(R.layout.list_item, parent, false) return ItemViewHolder(adapterLayout) } This was the definition the docs gave me, "Instantiates a layout XML file into its corresponding android.view.View objects." What...
  • u

    user

    06/28/2022, 7:11 PM
    Problems with a Kotlin Android app connected to Firebase I'm working on an Android app that lets you add consoles and games, serving as a library for games, that must be finished before Friday and after adding a new console, or even before, the Recyclerview in activity_dashboard_admin.xml shows the cardview and the delete icon but not element from the database in Firebase. If I click on any delete icon, nothing is removed from the Firebase database. On the other hand, the search function makes the app crash. I don't know what else to do and it's...
  • u

    user

    06/28/2022, 7:11 PM
    One Signal GmsLocationController ANR (App Not Responding) issue on Android I have an Android application on Google Play Store and I integrated firebase crashlytics to the project. Recently some of my users had an ANR issue which is: androidx.work-1 (waiting) tid=80 systid=9068 Root blocking sun.misc.Unsafe.park (Native method) com.google.android.gms.internal.location.zzz.requestLocationUpdates (com.google.android.gms:play-services-location@@20.0.0:5) com.onesignal.GMSLocationController$FusedLocationApiWrapper.requestLocationUpdates (GMSLocationController.java:201)...
  • u

    user

    06/28/2022, 7:51 PM
    Android - onClick function doesn't work in fragments i have a fragment in my quiz app and it has 4 buttons with onClick function " checkAnswer" like below, In activity it is okay to define the onClick func like fun checkAnswer(view : View){} But when i want to try it in a fragment, it doesn't work. I get an error: java.lang.IllegalStateException: Could not find method checkAnswer(View) in a parent or ancestor Context for android:onClick attribute defined on view class...
  • u

    user

    06/28/2022, 7:51 PM
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.loginpanel2/com.example.loginpanel2.MainActivity}:

    https://i.stack.imgur.com/z3nxH.pngâ–¾

    When I run my application, I get an "Application Stopped" error.
  • u

    user

    06/28/2022, 8:31 PM
    Android Check Picture in Picture from another activity When the user activates picture in picture mode and continues using the app, I need to change the behavior of the other activities. I tried to use: override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration ) { if (isInPictureInPictureMode) { // TODO } else { // TODO } } fun isPipActive(): Boolean { return if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ) {...
  • u

    user

    06/28/2022, 9:31 PM
    How to query all posts by tag_id in Postgres ManyToMany Relationship in spring JPA repository? How to query all posts by tag_id in Postgres ManyToMany relationship in Spring JPA repository? These are the tables: post post_tag tag id id_post id .. id_tag .. If I query the PostgreSQL directly via pg_admin Query tool the following sql is working: SELECT * FROM post WHERE ID IN ( select post_id from post_tag tag WHERE (tag_id = '12')) I like to have this query in my JPA Repository, but the following isn't working. @Query(value = "SELECT * FROM post WHERE ID IN (select post_id from...
  • u

    user

    06/28/2022, 9:31 PM
    Android app slow to start (6s to 10s in cold start) What really kills me, I did changes and changes over again(from layouts ...) to fight against this, what's really strange my app does not do heavy stuff(minimum functionality). I use 7 fragments, and FragmentContainerView , the default fragment contains just buttons to navigate to other fragments and adview I cleared fragments from codes, guess what stills slow in app start, which leaves two possibilities, either gradle or corrupt assets(vector only) my gradles: buildscript {...
  • u

    user

    06/28/2022, 10:11 PM
    Change return type to 'T' errror I override this function from ViewModelProvider.Factory but i get an error with the generic return type T Why ?

    https://i.stack.imgur.com/H3Gmg.pngâ–¾

    class NewsViewModelProviderFactory( val newsRepository: NewsRepository) : ViewModelProvider.Factory { override fun create(modelClass: Class): T { return NewsViewModel(newsRepository) as T } }
  • u

    user

    06/28/2022, 10:31 PM
    MVVM: Set a getDrawable from a ViewModel I'm moving all my app's logic from the fragment to the ViewModel and cannot move those methods that set drawables. Example: marker.icon = ContextCompat.getDrawable(requireContext(), R.drawable.waypoints_sq_blank) The reason being that the context is not reachable from a ViewModel. Any way I can get this to work?
  • u

    user

    06/28/2022, 11:51 PM
    CallbackFlow waiting for its inner flow to be collected I'm implementing firestore in my android app and I was wondering how I can make this code wait for its inner flow to be collected before running with the program. The trip.tripDays in the when expression is getting populated with data a time after Response.Success with my trips is already sent. override fun getTrips(idUser: String): Flow = callbackFlow { val trips = mutableListOf() tripsRef .whereEqualTo(ID_USER, idUser) .get()...
  • u

    user

    06/28/2022, 11:51 PM
    What is the name of the Long class in Kotlin JNI? This Kotlin function @JvmStatic external fun registerNativeWindowFromSurface(): Integer; is found by with return type java/lang/Integer but when I add a Long: @JvmStatic external fun registerNativeWindowFromSurface(id: Long): Integer; I cannot find it with java/lang/Long in the argument. Is Kotlin's Long a java long or a java/lang/Long? How can I get a Long class?
  • u

    user

    06/29/2022, 12:11 AM
    Is there a way to filter the exposed dropdown menu options depending on the value of another exposed dropdown menu in compose? So for example lets say I wanted the user to select a car on a car selection screen. The user would first select the car make they want from the first dropdown and depending on what make they choose the second menu would update and would show all the possible models for that specific make.
  • u

    user

    06/29/2022, 12:11 AM
    How to call this.superClassMethod on Kotlin? I have the following code: class MainActivity: FlutterActivity() { companion object { private val STREAM: String = "com.example.my_app/stream"; private lateinit var EVENT_CHANNEL: EventChannel init { EVENT_CHANNEL = EventChannel(this.getFlutterEngine().getDartExecutor().getBinaryMessenger(), STREAM) but I get Unresolved reference: getFlutterEngine, but the method exists: <a...
  • u

    user

    06/29/2022, 1:31 AM
    How can i use findViewById inside AsyncTask? i have an AsyncTask to execute while try connect phone to bluetooth device, i want change a icon from a button if it connect successefully (I'm new to Kotlin programming)

    https://i.stack.imgur.com/ucglB.pngâ–¾

    https://i.stack.imgur.com/9iBvp.pngâ–¾

    I would be very grateful if anyone could help
  • u

    user

    06/29/2022, 1:51 AM
    How does Kotlin's data class copy idiom look for nullable types? I have some code which looks like this, where param is of a data class type: val options = if (param.language == null) { param.copy(language = default()) } else { param } Now, however, the language object has been moved into a hierarchy of nullable objects, so the check must look like this: if (param.subObj?.nextObj?.language == null) { ... } How do I use the copy idiom in this case?
  • u

    user

    06/29/2022, 3:31 AM
    uninstall app fully still appears the error INSTALL_FAILED_VERSION_DOWNGRADE when I install my app background: I have installed the APK built by flutter with the 4.4.30 version. I want to install it back to 4.4.29 I uninstall the 4.4.30 app. I install the 4.4.29 package, and it will throw the error package appears to be invalid. I try to use ADB to install it, but the error will change to INSTALL_FAILED_VERSION_DOWNGRADE: Package Verification Result 6.no idea why the app built by flutter will cause this issue, even if I uninstall the app fully. the solution is using ADB install -r -d...
  • u

    user

    06/29/2022, 3:31 AM
    How to wait for suspend function to be completed before executing other code in kotlin I'm wondering if I can wait until a suspend function has completed before executing other code? loadParticlesWithoutSetCall, which I call inside of setParticlePicking, has a suspend function. I do not want anything else in setParticlePicking to be called until the suspend function has finished. Please let me know. fun setParticlePicking(particlePicking: ParticlePicking) { loadParticlesWithoutSetCall() manualParticleMarkers?.forEach { imageContainerElem.remove(it) }...
  • u

    user

    06/29/2022, 4:11 AM
    Bulid apk failed on flutter Linux zorin use visual studio code erik@erik-X455YA:~/PROJECT_FLUTTER/flutter_erikxz$ flutter build apk --release 💪 Building with sound null safety 💪 lib/main.dart:42:11: Error: Expected ',' before this. fit: BoxFit.cover), ^^^ lib/main.dart:41:11: Error: No named parameter with the name 'image'. image: DecorationImage(image: NetworkImage("https://images6.alphacoders.com/105/thumbbig-1059875.webp")) ^^^^^...
  • u

    user

    06/29/2022, 5:11 AM
    How do I use FlavorDimensions I am creating a dummy app for testing purposes. The Android app crashes everytime I use flavorDimensions. Please help flavorDimensions "tier" productFlavor { dev { dimension "tier" minSdkVersion rootProject.ext.minSdkVersion applicationId "com.awesomeproject.dev" targetSdkVersion rootProject.ext.targetSdkVersion resValue "string", "build_config_package", "com.awesomeproject"...
  • u

    user

    06/29/2022, 5:51 AM
    Kotlin: Most efficient way of comparing two list objects using - Webflux I have two lists each with 20,000 objects, the lists are two separate data types that I would like to compare. My two list objects types are shown below: List 1 type: data class FastUser( val fastUserId: String?, val fUserName: String?, ) List 2 type: data class SlowUser( val slowUserId: String?, val sUserName: String?, ) And finally my Result Type: data class Result( val slowUser: SlowUser, val fastUser: FastUser, val similarityScore: Int, // Can be between 0 - 1 only accepting >= 0.5 )...
  • u

    user

    06/29/2022, 5:51 AM
    Is their a better way to populate ignored column from another table using room I have two related tables item and purchase. The purchase class contains an ignored column itemName which I want to fill with itemName from item Although I have a method but I am concerned if there is a better way to achieve it because my way has to do with reading all items from the database then comparing purchase.itemOwnerID to item.itemID Here is my populating code along with others LaunchedEffect(key1 = true) { sharedViewModel.requestAllPurchases()...
  • u

    user

    06/29/2022, 6:11 AM
    how to set kotlin version for gradle runtime? Background Info: I am using jetpack compose for android developing and for some reason I CANNOT use gradle 7+. Currently I tried gradle 6.7.1 but it says ./gradlew -v ------------------------------------------------------------ Gradle 6.7.1 ------------------------------------------------------------ Build time: 2020-11-16 17:09:24 UTC Revision: 2972ff02f3210d2ceed2f1ea880f026acfbab5c0 Kotlin: 1.3.72 Groovy: 2.5.12 Ant: Apache...
  • u

    user

    06/29/2022, 6:11 AM
    How to Implement Fade In / Fade Out Animation in Horizontal Pager Android Compose Iam designing a Horizontal Pager in Android Jetpack Compose using googles accompanist Pager (implementation "com.google.accompanist:accompanist-pager:0.24.2-alpha"). I Implement this Horizontal Pager Correctly. But I want to change the default Animation of pager from horizontal left/ right swipe to fadein/ fadeout animation. Iam new to compose and i didn't find any useful resources in the internet. If anyone knows this help me to find the correct solutions. Thanks in Advance. val pagerState =...
  • u

    user

    06/29/2022, 6:31 AM
    Deserialize JsonArray with kotlinx serialization I have the following Json object: { "List":[ "string1", "string2", "string3", "..." ] } This deserializes into a JsonArray containing JsonLiterals. When deserializing this and trying to iterate over it I get an error: java.lang.ClassCastException: kotlinx.serialization.json.JsonLiteral cannot be cast to java.lang.String What would be the standard way to achieve something like that?
  • u

    user

    06/29/2022, 6:51 AM
    Get ImageView by ID on different kt file to set image which is in CardView of different kt file So basically I'm making an activity in which in button click one alert dialog displays on screen and it contain recyclerview with cardview and one close button. now, by clicking on cardview I have successfully toast a message but now there is requirement to get the image of cardview and then set it into imageview of different xml file (that cardview is also in different kt file). In short the main problem is i can not find that imageview into that different kt file. So, I have tried few...
Powered by Linen
Title
u

user

06/29/2022, 6:51 AM
Get ImageView by ID on different kt file to set image which is in CardView of different kt file So basically I'm making an activity in which in button click one alert dialog displays on screen and it contain recyclerview with cardview and one close button. now, by clicking on cardview I have successfully toast a message but now there is requirement to get the image of cardview and then set it into imageview of different xml file (that cardview is also in different kt file). In short the main problem is i can not find that imageview into that different kt file. So, I have tried few...
View count: 5