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
  • m

    Martin Sloup

    06/26/2020, 6:38 AM
    Hi guys, did someone solved issue with kapt3 and databinding, that kapt3 shows compilation errors without info/error messages from databinding? Kotlin 1.3.72 + Android Gradle Plugin 4.0.0
    [INFO] Processing java sources with annotation processors: [*redacted*]
    C:\Users\arcao\project\app\build\generated\source\kapt\debug\com\example\app\DataBinderMapperImpl.java:131: error: cannot find symbol
    import com.example.app.databinding.ViewListItemBindingImpl;
                                          ^
      symbol:   class ViewListItemBindingImpl
    Note: [1] Wrote GeneratedAppGlideModule with: [com.bumptech.glide.integration.okhttp3.OkHttpLibraryGlideModule]
    > Task :app:kaptDebugKotlin FAILED
      location: package com.example.app.databinding
    Untitled
    a
    r
    • 3
    • 2
  • l

    lawlorslaw

    06/26/2020, 3:56 PM
    and now i get this error:
    error: [Dagger/MissingBinding] java.lang.String cannot be provided without an @Inject constructor or an @Provides-annotated method.
    my class looks like this
    class InstructorProfileState @Inject constructor(
        val instructorId: String
    ) {
        sealed class ViewCommand {
            class SetInstructorData(val instructor: Instructor) : ViewCommand()
        }
    
        val viewCommandStream = SingleLiveEvent<ViewCommand>()
    }
    j
    • 2
    • 3
  • s

    Slackbot

    06/26/2020, 5:51 PM
    This message was deleted.
    :stackoverflow: 1
    👎 1
    o
    • 2
    • 1
  • r

    Remon Shehata

    06/26/2020, 6:23 PM
    Hello guys, I obfuscated my code to shrink it's size..etc using these lines
    minifyEnabled true
    shrinkResources true
    inside build grade(module:app) I have a few data classes that I want to keep as is. what should I search for?
    s
    • 2
    • 1
  • t

    Tomáš

    06/26/2020, 6:51 PM
    We are also going through Hilt transition as we speak if any one is interested https://github.com/toggl/android/pull/509/files We are still facing some issues but it should be ready to go soon. Hopefully we got the scoping and everything right.
    m
    • 2
    • 2
  • r

    rajesh

    06/27/2020, 5:41 AM
    Hi, anyone using Ktor for android to replace Retrofit? It looks simple like khttp library. Any guide is appreciated
    f
    r
    +2
    • 5
    • 12
  • s

    Slackbot

    06/27/2020, 2:18 PM
    This message was deleted.
    :google: 1
    👎 1
    :stackoverflow: 2
    o
    • 2
    • 1
  • a

    Azhar

    06/27/2020, 5:55 PM
    message has been deleted
    r
    • 2
    • 1
  • m

    manlan

    06/28/2020, 1:04 PM
    How do I show progress when using coroutines? e.g. The code is usually written in the attached way. If I want to show progress, I can start before making the call. But I'm not sure how to end the progress. I ideally want to stop showing the progress when the coroutine ends, but I'm not aware of any such mechanism. I'll have to observe the different possible results that I get from the call and call
    stopProgress()
    in each of the observers. Is there a better way? 😞 Can I make this generic so I do not have to do this in each and every fragment?
    z
    j
    • 3
    • 11
  • m

    Mo

    06/28/2020, 4:02 PM
    This is making all my questions null once it goes to the question as the submit button was pressed in q1, i need it to nullify the options once the submit button has been pressed in each question and then un-nullify when going to the next question. Rather than just nullifying the options for all questions once submit has been pressed in one. I guess once it goes to the next question, they should be tv_option_(number of option).setOnClickListener(this) again. Can't seem to get it to work. For context making a quiz app, any help appreciated!
    j
    • 2
    • 7
  • a

    Akram

    06/28/2020, 6:29 PM
    hello i'm trying to call the copy function by passing the
    KProperty
    it is working well in debugging , the problem is with r8 obfuscation i'm getting app crashing is there other way to do this ? here is my code
    a
    • 2
    • 2
  • t

    TarunY

    06/28/2020, 7:11 PM
    Hello guys, Leakcanary gives me the log as below. can someone please suggest me to resolve this.
    b
    • 2
    • 4
  • g

    Georgii Goncharik

    06/28/2020, 10:10 PM
    I'm sorry about the possible off-topic, but I don't know where else to write. Explain why it is returning null, please
    j
    a
    j
    • 4
    • 5
  • g

    Guy Bieber

    06/29/2020, 6:15 PM
    I have a keypair generated using the AndroidOpenSSL provider as follows:
    // Get the EC key generator. Has to be the OpenSSL version
            val kpg: KeyPairGenerator = KeyPairGenerator.getInstance(
                "EC", "AndroidOpenSSL")
    
            val parameterSpec = ECGenParameterSpec("AndroidOpenSSL)"
    
            //initialize and generate the keypair
            kpg.initialize(parameterSpec)
            val kp = kpg.generateKeyPair()
    I need to be able to store and retrieve this using the android keystore, however there doesn’t seem to be a way get the self signed certificate needed to store the key pair:
    val certArray : Array<Certificate> = arrayOf(certificate)
                //var certPath = PublicKeyToX509Cert(keyPair.public)
                keyStore.setKeyEntry(alias, keyPair.private.encoded, certArray)
    Basically the first certificate in the certArray needs to be the public key certificate. So the core question is how do I get from a publicKey to a certificate?
    • 1
    • 2
  • m

    Madalin Valceleanu

    06/29/2020, 6:30 PM
    📚 Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack. Application is based, apply and strictly complies with each of the following 5 points: • A
    single-activity architecture
    , using the Navigation component to manage fragment operations. • Android
    architecture components
    , part of Android Jetpack give to project a robust design, testable and maintainable. • Pattern
    Model-View-ViewModel
    (MVVM) facilitating separation of development of the graphical user interface. •
    S.O.L.I.D
    design principles intended to make software designs more understandable, flexible and maintainable. •
    Modular app architecture
    allows being developed features in isolation, independently from other features. Project link: https://github.com/VMadalin/android-modular-architecture
    ❤️ 7
    💯 7
    p
    • 2
    • 1
  • l

    luke_c

    06/30/2020, 1:48 PM
    Is this correct behaviour for a RadioButton? It’s not centred within its view boundaries, so when we add a TextView next to it there’s too much space
    h
    p
    v
    • 4
    • 6
  • j

    juliocbcotta

    07/02/2020, 12:04 PM
    Should inline classes work with Parcelize or is this a limitation? I have a Parcelable data class with an inline class id that I would like to send in a bundle...
    l
    • 2
    • 2
  • j

    Jabez Magomere

    07/02/2020, 1:18 PM
    Hey guys, I keep on getting
    viewModelFactory lateinit has not been initialized errpr
    when injecting a dagger view model factory into a fragment and initialising the viewmodel using viewmodel lazy delegate property, here is a snippet of my code.. Error :
    Fatal Exception: kotlin.UninitializedPropertyAccessException
    lateinit property viewModelFactory has not been initialized
    Code:
    class DeliveriesFragment() : Fragment(){
    
        @Inject
        lateinit var daggerViewModelFactory: DaggerViewModelFactory
        private val upcomingDeliveriesViewModel : UpcomingDeliveriesViewModel by viewModels { daggerViewModelFactory }
    
        override fun onAttach(context: Context) {
            SalesApplication.salesComponent().inject(this)
            super.onAttach(context)
        }
    
        override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
            super.onViewCreated(view, savedInstanceState)
            observeDeliveries()
        }
    
        private fun observeDeliveries(){
            upcomingDeliveriesViewModel.loadUpcomingUserDeliveries("").observe(viewLifecycleOwner, Observer {
                //displayList()
            })
        }
    }
    s
    k
    +3
    • 6
    • 6
  • r

    rahul_lohra

    07/03/2020, 4:46 PM
    hi anyone have any experience with bazel
    s
    • 2
    • 2
  • l

    Leon johnson

    07/04/2020, 4:05 AM
    I added an onclick listener to and edit text field but when the user selects the text field the Google's Place intent isn't loaded. I have to select the textfield again for the intent to load. I'm not sure why this is. can someone help... I've looked on Stackoverflow and google but can't find any solutions
    a
    • 2
    • 3
  • r

    RaptorDroid

    07/04/2020, 6:33 AM
    private val results = MediatorLiveData<Result>()
    private val dataSource = getData() // returns LiveData<Result>
    results.addSource(dataSource){data->
      if(hasNetwork){
        fetchDatafromNetwork(data)
      }else{
        results.value = data
      }
    }
    Hey guys I am new to RxJava and Android how can i write this in rxJava. what i mean is what can be used inplace of mediatorlivedata or how can this example can be written i nrxjava? Thanks
    r
    • 2
    • 3
  • n

    Nikola Milovic

    07/04/2020, 10:38 AM
    Any good multi module projects for Android that feature well structured gradle files? Like a Library base module that handles the dependancies. I cannot for the life of me find anything
    ➕ 2
    v
    • 2
    • 1
  • v

    Viktor VAD

    07/04/2020, 4:45 PM
    Hey, I am learning Android. I struggle to properly capture and react to the user's horizontal scrolling event across the screen. I'd like to touch the screen and with a horizontal scrolling motion I would like to update a number (TextView) on the screen, much like a traditional slider widget but the slider itself is the entire screen. I think I need to fiddle with
    GestureDetector
    like shown here. Can anyone link me some examples that I can learn from, please? I'm digging Google hard, but since I'm new, it's hard to ask the right questions.
    p
    • 2
    • 7
  • j

    jnyakush

    07/05/2020, 3:12 AM
    Hey everyone 👋 😁 having a long day My AS 4.0 is taking ages to build am using Kotlin DSL 🙂 it's now 15 minutes am working with a Dell machine Dell XPS is DSL stable yet 🤔
    g
    l
    +2
    • 5
    • 5
  • m

    manlan

    07/05/2020, 7:46 AM
    I am moving from Fragment A to Fragment B. When I press back button, Fragment A is recreated. I wish to avoid this. How do I do it? I am using Navigation Component e.g.
    findNavController().navigate(R.id.showDetailScreen)
    g
    v
    • 3
    • 3
  • m

    Myraboh

    07/06/2020, 7:26 AM
    Hello, how do I secure json files in asset folder before app release? Any who's done it before?
    :stackoverflow: 1
    g
    • 2
    • 1
  • s

    Slackbot

    07/06/2020, 8:42 AM
    This message was deleted.
    :stackoverflow: 1
    n
    s
    • 3
    • 4
  • s

    Slackbot

    07/06/2020, 10:29 AM
    This message was deleted.
    :stackoverflow: 2
    m
    j
    • 3
    • 13
  • s

    Slackbot

    07/06/2020, 3:14 PM
    This message was deleted.
    :stackoverflow: 1
    :kotlin: 1
    j
    n
    v
    • 4
    • 3
  • t

    Travis Griggs

    07/06/2020, 6:13 PM
    Why does the following line not work:
    this.mainLayout.removeCallbacks(this::stopConnecting)
    But if the following does:
    val stopConnectingRunnable = Runnable { this.stopConnecting() }
    this.mainLayout.removeCallbacks(this.stopConnectingRunnable)
    We thought (erroneously apparently and to much confusion/frustration) that the first would work.
    e
    m
    • 3
    • 2
Powered by Linen
Title
t

Travis Griggs

07/06/2020, 6:13 PM
Why does the following line not work:
this.mainLayout.removeCallbacks(this::stopConnecting)
But if the following does:
val stopConnectingRunnable = Runnable { this.stopConnecting() }
this.mainLayout.removeCallbacks(this.stopConnectingRunnable)
We thought (erroneously apparently and to much confusion/frustration) that the first would work.
e

ephemient

07/06/2020, 10:38 PM
why would you think that? it doesn't work like that in Java either
m

Mark Murphy

07/06/2020, 11:49 PM
removeCallbacks()
takes not just any
Runnable
, but the
Runnable
that you registered previously using
post()
or
postDelayed()
. So, you need to have a reference to the real
Runnable
that you used originally. If in your second code snippet you used
stopConnectingRunnable
for the original
postDelayed()
call (or whatever) and for the
removeCallbacks()
call, that is why it works. Conversely, if you let the compiler convert your function reference into a
Runnable
in both of those places, they would be different
Runnable
objects, and the
removeCallbacks()
one would not match the originally-registered one.
View count: 13