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

    Sam

    06/15/2021, 3:52 AM
    Hello everybody, Good Morning. I can not find this file
    AtomicInt
    Documentation: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.native.concurrent/-atomic-int/ My implement in Gradle:
    org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.31
    so Which libraries I should implement in project?
    g
    e
    • 3
    • 9
  • a

    Android75

    06/15/2021, 5:07 AM
    build.gradle.kts
    m
    • 2
    • 4
  • e

    Eder Sanchez

    06/15/2021, 6:40 AM
    Why enter twice?
    ``````
    g
    p
    • 3
    • 14
  • w

    Will Nixon

    06/15/2021, 3:27 PM
    Hey all - probably a dumb question, but does anyone here find that their app crashes on particular devices only? I have an app that crashes on a Huwawei device and a TCL device for the same reason, but doesn't happen on any other devices I've tested on (primarily google phones). How do you all solve those types of crash?
    a
    z
    +5
    • 8
    • 10
  • s

    Sudhir Singh Khanger

    06/15/2021, 5:41 PM
    Which is your preferred static analysis tool for Android/Kotlin?
    c
    j
    +2
    • 5
    • 10
  • j

    Jrichards1408

    06/16/2021, 9:07 AM
    Hi, i am getting issues trying to create a preference data store and getting this error despite adding the correct dependency:
    /ApplicationExtensions.kt: (8, 50): Unresolved reference: preferencesDataStore
    code below:
    import android.content.Context
    import androidx.datastore.core.DataStore
    import java.util.prefs.Preferences
    
    // At the top level of your kotlin file:
    val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "settings")
    In my gradle :
    implementation("androidx.datastore:datastore-preferences:1.0.0-beta01")
    e
    • 2
    • 1
  • j

    juliocbcotta

    06/16/2021, 1:39 PM
    What is the recommended API to use If I need to convert a UTC date/timestamp like “2021-03-04T23:00:00Z” to a local date in kotlin? • Threeten • java 8 with desugaring • Kotlin time/duration api
    d
    t
    • 3
    • 2
  • i

    Irene Serrano

    06/16/2021, 8:40 PM
    Hello, If anyone is familiar with using AChartEngine in their android projects, I would appreciate your help in trying to get a line of code to work. I am currently following this tutorial and I am stuck on the part wherein we create the View. I don't really know how to change this line to Kotlin and if I just pasted the line as is (in Java), Android Studio does not offer to translate the code for me. Any advice would be helpful, let me know if more information is needed
    🙌 1
    c
    • 2
    • 3
  • s

    Slackbot

    06/17/2021, 9:15 AM
    This message was deleted.
    :not-kotlin: 1
    g
    s
    • 3
    • 3
  • k

    KV

    06/17/2021, 1:51 PM
    Where to put a question related to UI issue for an example Constraint layout (xml) part?
    a
    l
    j
    • 4
    • 6
  • b

    Bagadeshkumar R

    06/17/2021, 4:22 PM
    Guys, been using compose lately. I don't see the equivalent of 'Fragment transition' in compose. I've been using navController with two different composable and trying to have animation between them. Can someone guide me?
    :not-kotlin: 1
    a
    w
    i
    • 4
    • 4
  • b

    Barry Fawthrop

    06/17/2021, 4:33 PM
    I'm looking for a non-licensed PDF Viewer for Android (Kotlin would be best) that allows for reading and writing of PDF Form data and loading from http url, thanks
    z
    p
    • 3
    • 4
  • b

    Bradleycorn

    06/17/2021, 8:24 PM
    Has anyone else run into numerous problems with 
    jacoco
     since updating Android Studio to version 4.2.1? First I could not run unit tests at all, they would error with class not found errors. I was able to resolve that by excluding jdk internal classes (
    jacoco.excludes = ['jdk.internal.*']
    ). But now my coverage reports show 0% coverage, and I get a bunch of build output messages saying that “execution data for class  xyz does not match”.  I cant’ figure out how to solve that one? It seems to be something in the AGP. If I roll the AGP back to v4.1.3 everything works fine. But as soon as I update to 4.2.0 suddenly I get 0% in my coverage report along with the “execution data for class…” warnings in the build output.
    :not-kotlin: 1
    k
    • 2
    • 6
  • i

    Irene Serrano

    06/17/2021, 10:16 PM
    Hello, I am having an issue with a lateinit variable that I am unsure on how to fix. With the code as is, the variable in question does get initialized within a while loop but because of this, AndroidStudio throws a
    lateinit property series has not been initialized
    error. I don't really know what a good work around would be, any advice would be helpful? Thanks To give background, I am trying to create a line graph using GraphView library
    // create a new data series
            lateinit var series: LineGraphSeries<DataPoint>
            // link activity to layout view
            val graph: GraphView = findViewById(R.id.line_chart)
    
            // try to read and save data into series
            val minput = InputStreamReader(assets.open("tester_data_CSV.csv"))
            val reader = BufferedReader(minput)
            var line: String
            var x: Double
            var y: Double
            while (reader.readLine().also { line = it } != null) {
                val row: List<String> = line.split(",")
                x = row[0].toDouble()
                y = row[1].toDouble()
                // add data to series, unsure what the last element is for
                series.appendData(DataPoint(x,y),true,  100)
            }
            // add series to graph
            graph.addSeries(series)
    f
    k
    • 3
    • 3
  • h

    haris mehmood

    06/18/2021, 11:45 AM
    Hello, I'm using this method
    binding?.bottomAppBar?.setupWithNavController(findNavController(R.id.nav_host))
    but whenever i tab to any item on bottomBar its calling api again again
    :not-kotlin: 6
    z
    • 2
    • 2
  • v

    vapoyan

    06/18/2021, 2:08 PM
    Hey I have following problem
    private var socket: DatagramSocket = .... 
    
    fun startListening() {
        while (socket != null) {
            socket?.receive(packet) // we are blocked here untill we receive packet
        }
    }
    How I can implement this with coroutines, so it's running async and not blocking ?
    c
    • 2
    • 2
  • a

    Aniket Khajanchi

    06/19/2021, 1:34 PM
    In recycler view what difference does "setHasFixedSize(true)" make? I checked online and toggled between true and false but it makes no difference in my app.
    :not-kotlin: 11
    z
    • 2
    • 1
  • e

    eygraber

    06/20/2021, 7:36 PM
    Anyone using Arctic Fox Beta 4 with Kotlin without trouble?
    👍 2
    :yes: 3
    z
    • 2
    • 2
  • m

    mario

    06/21/2021, 10:17 AM
    Hello, new compose project in beta articfox generate this problems, everithing is red
    a
    • 2
    • 6
  • a

    André Thiele

    06/22/2021, 12:19 PM
    [SOLVED] What's the best way to apply insets in a PreferenceFragment? Simply adding the insets does not work because it moves the entire ScrollView to the top, I want just a padding on the bottom inside the scrollview. How do I get the RecyclerView used by the PreferenceFragment?
    :not-kotlin: 4
    • 1
    • 1
  • z

    Zakayo Thuku

    06/22/2021, 12:54 PM
    Anyone with experience using includeBuild() with custom plugins or external plugins? Facing some weird issues when I apply the plugin to my application
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    com/android/build/gradle/AppExtension
    > com.android.build.gradle.AppExtension
    
    * Exception is:
    java.lang.NoClassDefFoundError: com/android/build/gradle/AppExtension
    	at com.guardsquare.dexguard.gradle.DexGuardPlugin.apply(DexGuardPlugin.kt:47)
    	at com.guardsquare.dexguard.gradle.DexGuardPlugin.apply(DexGuardPlugin.kt:27)
        ....
    Caused by: java.lang.ClassNotFoundException: com.android.build.gradle.AppExtension
    	... 195 more
    v
    • 2
    • 2
  • f

    FunkyMuse

    06/22/2021, 2:05 PM
    hey guys, when i'm clicking on the bottom navigation items really fast I get a crash i'm using navigation component 2.4.0-alpha03 and fragment 1.4.0-alpha03
    Fatal Exception: java.lang.IllegalArgumentException: saveBackStack("11cd317d-581d-457d-b8b3-167e3461edae") must be self contained and not reference fragments from non-saved FragmentTransactions. Found reference to fragment HealthFragment(categoryActionId=2131362017) in BackStackEntry{2e799a4 11cd317d-581d-457d-b8b3-167e3461edae} that were previously added to the FragmentManager through a separate FragmentTransaction.
    :not-kotlin: 2
    i
    • 2
    • 3
  • a

    Akash Amin

    06/22/2021, 5:16 PM
    Hi, I have an issue with compose, I am using ComposeView in a ViewHolder to my existing RecyclerViewAdapter which resides inside a Swipeable ViewPager. The ComposeView has a LazyRow which shows a list of cards. The issue is: When I am trying to scroll the LazyRow the ViewPager scroll intercepts which makes it difficult to scroll the items in the LazyRow. I think this is something to do with the ComposeView not able to identify the ViewTree. I have detailed the implementation on this SO question https://stackoverflow.com/questions/68038792/scroll-issues-with-lazyrow-inside-traditional-android-viewpager
    i
    • 2
    • 2
  • c

    Christy Jacob

    06/22/2021, 6:19 PM
    Hey everyone, I've successfully published an android library to Maven's Snapshot repo (https://s01.oss.sonatype.org/content/repositories/snapshots/io/appwrite/sdk-for-android/) When I examine the POM file, all the intended dependencies are present as well. So I create a new Android project to consume this library. I add the snapshot repository URL to my project's build.gradle
    repositories {
        maven {
            url "<https://s01.oss.sonatype.org/content/repositories/snapshots/>"
        }
    }
    I then add my dependency
    dependencies {
       implementation("io.appwrite:sdk-for-android:0.0.0-SNAPSHOT")
    }
    Now I try to sync my Gradle files and I'm faced with this error.
    Failed to resolve: com.github.franmontiel:PersistentCookieJar:v1.0.1
    This is in fact a transitive dependency from my library (https://github.com/appwrite/sdk-for-android/blob/main/library/build.gradle#L71) I'm now forced to add the jitpack maven repo to my example app as well, after which the error disappears.
    repositories {
        maven {
            url "<https://s01.oss.sonatype.org/content/repositories/snapshots/>"
        }
        maven { url "<https://jitpack.io>" }
    }
    Is there a way to avoid adding this repository ? My library's pom file already contains this dependency. (https://s01.oss.sonatype.org/content/repositories/snapshots/io/appwrite/sdk-for-android/0.0.0-SNAPSHOT/sdk-for-android-0.0.0-20210617.055649-2.pom). Is there a way for gradle to automatically fetch this dependency without me having to add the jitpack repository ? I would not expect my end users to add an additional repository. Thank you for your help 🙂
    c
    • 2
    • 2
  • l

    Lilly

    06/22/2021, 7:18 PM
    I have a class which behaves like a Singleton. I want to set its state in the data layer and want to use it as read-only object in the presenter. The state will be just 2 or 3 observable flags, like MutableStateFlow. How can I make the state of this object mutable in data layer but immutable in presentation layer?
    s
    • 2
    • 6
  • p

    Pedro Azevedo

    06/22/2021, 11:05 PM
    Hi guys , does anybody have experience on Google Firebase ?
    :not-kotlin: 7
    s
    • 2
    • 1
  • h

    haris mehmood

    06/23/2021, 10:15 AM
    hI, I'm using navigation component but on back press its recreating the fragment any solution for this ? Thanks
    :not-kotlin: 4
    s
    • 2
    • 1
  • j

    Joshua

    06/23/2021, 2:43 PM
    Any clue why the button appears white when it is orange when i design it?
    :not-kotlin: 7
    r
    • 2
    • 12
  • e

    eschrag

    06/23/2021, 3:21 PM
    can anyone link me to documentation that shows you shouldn’t disable the back button? i know this is incredibly unusual to do but can’t find official support that shows you shouldn’t do this for a designer.
    :not-kotlin: 4
    z
    r
    +2
    • 5
    • 13
  • b

    Bradleycorn

    06/23/2021, 8:30 PM
    In terms of making classes/methods open for mocking in unit tests … is the best solution for that still to use the kotlin
    all-open
    plugin, and define annotations in debug and release sourceSets so that annotated classes become open in debug builds, but final in release builds? This is the solution we’ve been using for some time, and it works, no question. But it’s not perfect, because what we really want is for the classes to only be open when running tests, but instead they are open anytime you are doing a debug build, whether for tests or otherwise. I know mockito introduced “inline-mock-maker” awhile back, and at the time it didn’t work with Robolectric. Is that still the case? Is there some other “new and improved” way to keep classes as final but allow them to be mocked in unit tests?
    j
    • 2
    • 4
Powered by Linen
Title
b

Bradleycorn

06/23/2021, 8:30 PM
In terms of making classes/methods open for mocking in unit tests … is the best solution for that still to use the kotlin
all-open
plugin, and define annotations in debug and release sourceSets so that annotated classes become open in debug builds, but final in release builds? This is the solution we’ve been using for some time, and it works, no question. But it’s not perfect, because what we really want is for the classes to only be open when running tests, but instead they are open anytime you are doing a debug build, whether for tests or otherwise. I know mockito introduced “inline-mock-maker” awhile back, and at the time it didn’t work with Robolectric. Is that still the case? Is there some other “new and improved” way to keep classes as final but allow them to be mocked in unit tests?
j

Jeremy

06/23/2021, 8:54 PM
Have you tried
mockk
?
b

Bradleycorn

06/23/2021, 8:56 PM
I’ve looked at it. Haven’t used it myself. Research seems to indicate it’s fairly slow compared to mockito.
however, it seems that recent versions of mockito and robolectric have mitigated the issues above. I was able to write a test just now and successfully mock a kotlin (i.e. final) class.
➕ 1
j

Jeremy

06/23/2021, 8:58 PM
Have not benchmarked the unit tests mocks but have not experienced issue described in a long time due to interfaces/fakes and mockk
View count: 6