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
android
  • s

    Slackbot

    04/27/2021, 2:47 AM
    This message was deleted.
    :not-kotlin: 1
    j
    • 2
    • 1
  • u

    ursus

    04/27/2021, 3:02 AM
    Kotlin 1.5.0 makes lint blow up on
    forEach
    createProcessors.forEach { it.process(db) }
    
    Error: Call requires API level 24 (current min is 21): java.lang.Iterable#forEach [NewApi]
              createProcessors.forEach { it.process(db) }
                               ~~~~~~~
    That can't be right, no?
    v
    • 2
    • 2
  • t

    tateisu

    04/27/2021, 5:26 AM
    also I think it's android lint problem, not kotlin compiler.
    u
    • 2
    • 1
  • c

    Cheolho Jeon

    04/27/2021, 7:48 AM
    Hi all, I'm a android library developer who recently added Kotlin to my library - I added it like this
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.31"
    and as a result it seems like I'm suddenly exceeding 64k method count and required to use multidex. Is it expected? I thought only several, used methods will be added to my final binary.
    d
    j
    m
    • 4
    • 5
  • r

    Remy Benza

    04/27/2021, 12:18 PM
    Is there a way to let a NotificationListenerService block notifications that contain a full screen Intent?
    :stackoverflow: 3
    :not-kotlin: 5
    a
    l
    • 3
    • 17
  • h

    Hovhannes

    04/27/2021, 2:04 PM
    Hello everyone, can I test my app without Mockito and use only Espresso and JUnit?
    :not-kotlin: 3
    e
    p
    u
    • 4
    • 7
  • m

    Mark

    04/27/2021, 2:55 PM
    I’m having an issue where
    RecyclerView
    scroll position is being nondeterministically ‘forgotten’ due to the adapter being updated via the collection of a
    StateFlow
    (in `Fragment.onCreateView()`:
    val myAdapter = // create it
    viewModel.itemsFlow.collectInViewScope(this) { items ->
        myAdapter.setItems(items)
    }
    recyclerView.adapter = myAdapter
    As a workaround (which seems to work), I just delay setting the adapter until the first search results come in:
    viewModel.itemsFlow.collectInViewScope(this) { items ->
        myAdapter.setItems(items)
        with(recyclerView) {
            if (adapter == null) {
                adapter = myAdapter
            }
        }
    }
    However, this feels like a hack. What is the correct way to
    collect
    adapter items and update the adapter so that the scroll position is not lost (when returning from a downstream fragment)?
    :not-kotlin: 1
    j
    a
    • 3
    • 3
  • r

    Ravi

    04/28/2021, 7:07 AM
    in android studio canary 14 im unable to see jdk location in project structure
    • 1
    • 1
  • v

    Vivek Modi

    04/28/2021, 10:54 AM
    Hi i have data class.
    d*ata class Customer(val item: int,val name : String)
    .* i want to pass through bundle.
    val bundle = Bundle()
    but i didn't get which one i used putParcelable or something else.
    bundle.*putParcelable("customer, Customer(1,"X")")*
    . It giving error Customer is not parcelable
    a
    d
    +3
    • 6
    • 14
  • s

    Slackbot

    04/28/2021, 6:49 PM
    This message was deleted.
    c
    • 2
    • 1
  • m

    mittapalli hareesh

    04/29/2021, 4:41 AM
    hi All, Gd mrg !! In my project i have integrated roboelectric test dependency, while i am building app via Jenkins facing below error
    ERROR: Failed to fetch maven artifact org.robolectric:android-all:9-robolectric-4913185-2
    
    11:09:22  2021-04-28T11:09:21.613+0530 [DEBUG] [TestEventLogger]     java.util.concurrent.ExecutionException: java.net.ConnectException: Operation timed out (Connection timed out)
    due to this all my unit-test cases are failing & finally build failing. Can anyone help how to resolve this issue ? Similar Stackoverflow ticket is https://stackoverflow.com/questions/60710693/robolectric-fails-to-download-connection-time-out
    :not-kotlin: 8
    k
    • 2
    • 1
  • v

    Vivek Modi

    04/29/2021, 3:07 PM
    Hi how to get last two word for string. if i have sentence like this
    Hey! well done men
    . How can i get substring
    done men
    in kotlin. Anyone knows the easiest way
    z
    r
    • 3
    • 9
  • r

    Raed Ghazal

    04/29/2021, 10:36 PM
    isn't this channel for android stuff?
    :kotlinnew: 1
    e
    • 2
    • 1
  • a

    aravind

    04/30/2021, 6:47 AM
    Hi, i am trying to send an event through SDK to android using SharedFlow while i using take() the flow didn’t collect the event if i use collect without take() it continuously collects the event can anyone help
    d
    • 2
    • 2
  • s

    Saiedmomen

    04/30/2021, 7:15 AM
    After updating to the latest Android studio Canary and AGP-alpha15, all my android config in gradle kotlin became undefined. As if the AGP doesn't exist.
    ➕ 2
    m
    a
    +2
    • 5
    • 13
  • s

    Socheat KHAUV

    04/30/2021, 4:44 PM
    I ran android emulator inside macOS Bigsur. and emulator is having with host webcam, anyone have know how to fix that ?
    :google: 2
    :not-kotlin: 7
    l
    • 2
    • 2
  • r

    Ravi

    05/01/2021, 8:39 PM
    hi all, We are trying compose and our existing reactnative related tasks of gradle causing issues only in canary
    15
    and working fine in stable version of android studio, can anyone help
    Script 'xxxxxxx/reactNative/node_modules/react-native/react.gradle' line: 99
    * What went wrong:
    A problem occurred evaluating script.
    > Cannot run Project.afterEvaluate(Closure) when the project is already evaluated.
    🍕 2
    :stackoverflow: 4
    :google: 3
    :not-kotlin: 6
    🍆 3
    c
    • 2
    • 1
  • a

    AJIBOLA ODUJOLE

    05/02/2021, 11:05 AM
    private fun signIn() {
        val email = findViewById<TextInputEditText>(R.id.email_edit_text)
        val password = findViewById<TextInputEditText>(R.id.password_edit_text)
        val signInButton = findViewById<MaterialButton>(R.id.next_button)
    
        signInButton.setOnClickListener(){
            if (email.toString().isEmpty() || password.toString().isEmpty()){
                Toast.makeText(this, "Email or Password is not Provided", Toast.LENGTH_SHORT).show()
            } else {
                if (email.toString() == "<mailto:ajibs@gmail.com|ajibs@gmail.com>" && password.toString() == "234567"){
                    val intent = Intent(this, ViewActivity::class.java)
                    startActivity(intent)
                } else {
                    Toast.makeText(this, "Wrong email or password", Toast.LENGTH_LONG).show()
                }
            }
        }
    }
    Hello everyone, A newbie on this streets, I have login screen I created It's failing to go to the next screen. Please feedback on the code block. Its output is always wrong email or password
    j
    • 2
    • 3
  • m

    mohamadreza jafarzade

    05/03/2021, 9:07 AM
    Hi. I have a FirebaseMessagingService and i want to update a running activity when special message comes from firebase. How i can do that?
    :not-kotlin: 5
    b
    d
    • 3
    • 5
  • m

    Mohan Babu Malairaj

    05/03/2021, 10:12 AM
    Hi, I would like to know if it would be possible to use two DI frameworks in one android project, main app with dagger2 and one library with koin, and also would there be issues ? anyone has experience ? Thank you.
    j
    • 2
    • 6
  • s

    Slackbot

    05/04/2021, 1:11 PM
    This message was deleted.
    :not-kotlin: 6
    l
    • 2
    • 1
  • v

    Vivek Modi

    05/04/2021, 1:31 PM
    I want to find index from string. How can i find the index of the first alphabet of second last word in a string.
    val index = "Hey! How are you men? How you doing"
    i want to search you doing from the above string, but i want y index from the word you. I did some code to find index but I am unable to find it.
    fun main(vararg args: String) {
        val inputString = "Hey! How are you men? How you doing"
        val regex = "you doing".toRegex()
        val match = regex.find(inputString)!!
        println(match.value)
        println(match.range)
    }
    l
    t
    • 3
    • 14
  • i

    iamthevoid

    05/04/2021, 2:23 PM
    Did anybody meet the strange exception with firebase crash reportiong?
    E/FirebaseCrashlytics: Error handling uncaught exception
        java.util.concurrent.TimeoutException
            at com.google.firebase.crashlytics.internal.common.Utils.awaitEvenIfOnMainThread(Utils.java:122)
            at com.google.firebase.crashlytics.internal.common.CrashlyticsController.handleUncaughtException(CrashlyticsController.java:231)
            at com.google.firebase.crashlytics.internal.common.CrashlyticsController$1.onUncaughtException(CrashlyticsController.java:153)
            at com.google.firebase.crashlytics.internal.common.CrashlyticsUncaughtExceptionHandler.uncaughtException(CrashlyticsUncaughtExceptionHandler.java:54)
            at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1073)
            at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
            at java.lang.Thread.dispatchUncaughtException(Thread.java:2187)
    Added with firebase bom (27.1.0) and dependency
    com.google.firebase:firebase-crashlytics-ktx
    . Checked that with emulator and physical device (both without internet issues on quick look). How can it be?
    • 1
    • 5
  • f

    Fares Othmane Mokhtari

    05/04/2021, 9:55 PM
    I wanna build my CICD pipeline for android project , but I don't have any idea could anyone help me please from where should I start to build the pipeline
    :not-kotlin: 10
    s
    s
    e
    • 4
    • 5
  • u

    ubu

    05/05/2021, 10:31 AM
    Hello there, did you have any trouble with 
    Room
     compiler when switching to Kotlin 
    0.1.5
    ?
    i
    • 2
    • 3
  • f

    Felipe Passos

    05/05/2021, 11:41 AM
    Hello, how do i update a variable using a retrofit2 callback? I was expecting the place_name variable update the value in this code :
    • 1
    • 1
  • m

    Manoj

    05/05/2021, 11:55 AM
    I have some code in Java like this -
    ArrayList<String> arr = new ArrayList<>();
            arr.add("1");
            arr.add("2");
            arr.add("3");
            arr.add("4");
            arr.add("5");
            
            for (int i = 0; i < arr.size(); i++) {
                if(i == 3) {
                    arr.remove(i);
                } else {
                    System.out.println(arr.get(i) + "\n");
                }
            }
    & I have converted the same code in Kotlin -
    val arr = ArrayList<String>();
        arr.add("1")
        arr.add("2")
        arr.add("3")
        arr.add("4")
        arr.add("5")
        for (i in 0 until arr.size) {
            if(i == 3) {
                arr.removeAt(i)
            } else {
            	println("Value ${arr.get(i)}")
            }
        }
    bt it gives Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 4, Size: 4 but works in Java without exception... Anyone has any idea what's wrong here?
    i
    r
    • 3
    • 13
  • m

    Mark

    05/05/2021, 1:01 PM
    After updating to android build tools 4.2.0, I get a build failure when I remove this (I’ll update this with more detail when I get the chance)
    kotlinOptions {
        jvmTarget = "1.8"
    }
    t
    n
    • 3
    • 7
  • s

    Slackbot

    05/05/2021, 3:18 PM
    This message was deleted.
    :not-kotlin: 2
    k
    • 2
    • 1
  • t

    trevjones

    05/05/2021, 6:55 PM
    So i am running into issues upgrading from kotlin 1.4.32 to 1.5 due to all of our pure kotlin libraries using junit5, some of those libraries provide test-fixtures for downstream tests which then expose helpers built up on both junit4 and junit5. Plus the android unit tests are still on junit4. My initial thought was just update the android unit test configuration to use junit5 with the legacy runner, but some of those test fixtures are also going to have issues on the androidTest configs, which junit 5 in that setting becomes much less real of an option. anyone else ran into something like this?
    Cause 1: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.jetbrains.kotlin:kotlin-test-junit:1.5.0.
    Required by:
        project :app
    Caused by: org.gradle.api.GradleException: Module 'org.jetbrains.kotlin:kotlin-test-junit' has been rejected:
       Cannot select module with conflict on capability 'org.jetbrains.kotlin:kotlin-test-framework-impl:1.5.0' also provided by [org.jetbrains.kotlin:kotlin-test-junit5:1.5.0(junit5Api)]
    ...
    Cause 2: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.jetbrains.kotlin:kotlin-test-junit5:1.5.0.
    Required by:
        project :app > project :appStartup
        project :app > project :flow-ext
        project :app > project :json-ext
        project :app > project :retrofit-ext
        project :app > project :session-data
    Caused by: org.gradle.api.GradleException: Module 'org.jetbrains.kotlin:kotlin-test-junit5' has been rejected:
       Cannot select module with conflict on capability 'org.jetbrains.kotlin:kotlin-test-framework-impl:1.5.0' also provided by [org.jetbrains.kotlin:kotlin-test-junit:1.5.0(junitApi)]
    • 1
    • 1
Powered by Linen
Title
t

trevjones

05/05/2021, 6:55 PM
So i am running into issues upgrading from kotlin 1.4.32 to 1.5 due to all of our pure kotlin libraries using junit5, some of those libraries provide test-fixtures for downstream tests which then expose helpers built up on both junit4 and junit5. Plus the android unit tests are still on junit4. My initial thought was just update the android unit test configuration to use junit5 with the legacy runner, but some of those test fixtures are also going to have issues on the androidTest configs, which junit 5 in that setting becomes much less real of an option. anyone else ran into something like this?
Cause 1: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.jetbrains.kotlin:kotlin-test-junit:1.5.0.
Required by:
    project :app
Caused by: org.gradle.api.GradleException: Module 'org.jetbrains.kotlin:kotlin-test-junit' has been rejected:
   Cannot select module with conflict on capability 'org.jetbrains.kotlin:kotlin-test-framework-impl:1.5.0' also provided by [org.jetbrains.kotlin:kotlin-test-junit5:1.5.0(junit5Api)]
...
Cause 2: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.jetbrains.kotlin:kotlin-test-junit5:1.5.0.
Required by:
    project :app > project :appStartup
    project :app > project :flow-ext
    project :app > project :json-ext
    project :app > project :retrofit-ext
    project :app > project :session-data
Caused by: org.gradle.api.GradleException: Module 'org.jetbrains.kotlin:kotlin-test-junit5' has been rejected:
   Cannot select module with conflict on capability 'org.jetbrains.kotlin:kotlin-test-framework-impl:1.5.0' also provided by [org.jetbrains.kotlin:kotlin-test-junit:1.5.0(junitApi)]
solution
configurations.all {
        resolutionStrategy.capabilitiesResolution
            .withCapability("org.jetbrains.kotlin:kotlin-test-framework-impl:$kotlinVersion") {
                val junit4 = candidates.find { (it.id as? ModuleComponentIdentifier)?.module == "kotlin-test-junit" }
                val junit5 = candidates.find { (it.id as? ModuleComponentIdentifier)?.module == "kotlin-test-junit5" }
                if(useJunit5) junit5?.let { select(it) }
                else junit4?.let { select(it) }
            }
    }
View count: 11