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

    bj0

    11/08/2017, 5:47 PM
    if you get
    NumberFormatException
    than your string probably isn't able to be represented as a
    Long
    k
    m
    10 replies · 3 participants
  • m

    Minty

    11/09/2017, 8:40 AM
    I'm getting compile error and Android studio lags a lot if I put i if I put it in the Main activity class as a string
    r
    1 reply · 2 participants
  • k

    kingsley.gomes

    11/09/2017, 11:24 AM
    Hi, I'm new to kotlin how can i return data from an anonymous function?
    val flowable = mWebService?.getData
                flowable?.subscribeOn(<http://io.reactivex.schedulers.Schedulers.io|io.reactivex.schedulers.Schedulers.io>())
                        ?.subscribe({ response ->
                            Logger.i(TAG, "onNext $response")
                            return true //<------------ how do I return this
                        }, { throwable ->
                            Logger.i(TAG, "onError $throwable")
                        }, {
                            Logger.i(TAG, "onCompleted")
                        })
    g
    m
    +1
    4 replies · 4 participants
  • k

    kenkyee

    11/09/2017, 11:28 AM
    Switch to using coroutines. You can't use Rx that way...has nothing to do with Kotlin...
    g
    p
    8 replies · 3 participants
  • k

    khanhbkqt

    11/10/2017, 2:39 AM
    Hi, does anyone know this error: Error:Execution failed for task ':app:transformClassesWithJarMergingForDevDebug'.> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/webrtc/Camera1Session$2.class Duplicate class of 2 library twilio and Sora
    g
    1 reply · 2 participants
  • r

    Regan Russell

    11/10/2017, 3:52 AM
    android-united.slack.com
    k
    h
    +1
    5 replies · 4 participants
  • m

    Minty

    11/10/2017, 7:14 AM
    Never mind fixed it.
    h
    1 reply · 2 participants
  • r

    rkeazor

    11/10/2017, 1:08 PM
    Hey has anyone tried the Koin Dependency injection library on a large project?
    r
    s
    +1
    8 replies · 4 participants
  • n

    nil2l

    11/10/2017, 1:22 PM
    It seems not ready for MVVM yet.
    r
    3 replies · 2 participants
  • n

    noahconnors

    11/10/2017, 2:23 PM
    Hey, does anyone have any good starter tutorials for android using kotlin?
    t
    s
    4 replies · 3 participants
  • r

    rkeazor

    11/11/2017, 7:35 PM
    Hey whats better , Anko or XML with data binding. if you were creating a production app which one would you choose
    k
    r
    +2
    4 replies · 5 participants
  • r

    rwachol

    11/11/2017, 10:36 PM
    hello, should I still use kapt for android with AS 3.0 or I can use default annotationProcessor ?
    r
    r
    +1
    5 replies · 4 participants
  • p

    Pavlo Liapota

    11/13/2017, 7:54 AM
    also you can write
    0 -> { -> FragmentA() }
    a
    1 reply · 2 participants
  • k

    Kulwinder Singh

    11/13/2017, 10:08 AM
    Realm
    realm.where(DataPan::class.java).findAll().deleteAllFromRealm()
    only deletes DataPan but not fields that are inside
    DataPan
    like
    time
    of type
    TimeInfo
    is not deleted (edited) please anybody help with this
    :stackoverflow: 2
    a
    1 reply · 2 participants
  • o

    oday

    11/13/2017, 11:03 AM
    I know I can add them to compositeDisposable object and then clear it later, but do I have just 1 compositeDisposable for the whole app or per activity?
    :stackoverflow: 4
    d
    1 reply · 2 participants
  • m

    mnawrot

    11/13/2017, 12:37 PM
    hello there ✋ im trying to create generic
    BaseViewModelFactory<VM>
    class to provide new architecture component's view models. i wanted to call
    isAssignable(...)
    function before i create actual viewmodel, to check if everything is fine, but in order to do that, the viewmodel type
    VM
    have to be reified and i dont know how to call inline reified function from overriden
    ViewModelProviders.Factory create()
    function currently i got something like this :
    abstract class BaseViewModelFactory<out VM : Any>(private val viewModelClass: KClass<VM>) : ViewModelProvider.Factory {
    
        @Suppress("unchecked_cast")
        override fun <T : ViewModel?> create(modelClass: Class<T>): T {
            require(modelClass.isAssignableFrom(viewModelClass.java)) {
                "Could not instantiate ${javaClass.simpleName} class"
            }
            return createViewModel() as T
        }
    
        abstract protected fun createViewModel(): VM
    }
    is there a way to avoid passing viewModelClass in constructor and somehow use reified type parameter here?
    l
    y
    +1
    9 replies · 4 participants
  • e

    Eduard Boloș

    11/13/2017, 7:53 PM
    do you mean toggling between two images for a background or such? because clicked is not a state, pressed is 😕
    n
    1 reply · 2 participants
  • i

    itnoles

    11/13/2017, 9:44 PM
    I think I downloaded a wrong 1.1.60 plugin for Android Studio 3.1 because I am getting "Gradle sync failed: com.android.tools.idea.gradle.project.model.AndroidModuleModel.getSelectedVariant()Lcom/android/tools/idea/gradle/project/model/ide/android/IdeVariant; (6s 648ms)"
    n
    2 replies · 2 participants
  • n

    neuber

    11/14/2017, 12:01 AM
    yes You are correct
    k
    v
    9 replies · 3 participants
  • e

    edwardwongtl

    11/14/2017, 8:12 AM
    Because the names already matches
    h
    1 reply · 2 participants
  • m

    menegatti

    11/14/2017, 8:16 AM
    iirc,
    IDENTITY
    is the default one, which means gson will convert fields whose names are exactly the same as the keys in your json object
    h
    1 reply · 2 participants
  • p

    Paul Woitaschek

    11/14/2017, 11:02 AM
    I have all these ..kotlin_module files ranging at 2-5 kb each
    v
    p
    3 replies · 3 participants
  • a

    adinugroho

    11/14/2017, 4:08 PM
    Never tried JaCoCo before, but, I remembered when I want to try mockk (https://github.com/oleksiyp/mockk#2-add-class-modification-via-annotation) there’s an information if I want to use mockk with JaCoCo, I must use agent. I don’t know if this is related with your question but I hope it can help.
    👍 1
    r
    1 reply · 2 participants
  • s

    sngrekov

    11/14/2017, 4:23 PM
    @Ricardo: https://kotlinlang.slack.com/archives/C0B8M7BUY/p1510675261000179 We have no problems while using kotlin and Jacoco.
    r
    3 replies · 2 participants
  • t

    tgmcians

    11/14/2017, 5:04 PM
    I uninstalled latest kotlin plugin from android studio, I didn't find a way to download old version.
    a
    3 replies · 2 participants
  • f

    Federico Oldrini

    11/15/2017, 9:20 AM
    Hi, after updating the plugin to to 1.1.60 i get this error on gradle project sync: 'Gradle sync failed: com.android.tools.idea.gradle.project.model.AndroidModuleModel.getSelectedVariant()Lcom/android/tools/idea/gradle/project/model/ide/android/IdeVariant'. I can solve downgrading
    v
    2 replies · 2 participants
  • m

    Minty

    11/15/2017, 9:31 AM
    Can anyone recommend a free cloud based IDE for anroid dev with kotlin support
    a
    1 reply · 2 participants
  • s

    smilecs

    11/15/2017, 1:47 PM
    all right problem solved forgot i was using this before we changed the response pattern from the api…
    private fun providesGson(): Gson {
            val gsonBuilder = GsonBuilder()
            gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
            return gsonBuilder.create()
        }
    y
    2 replies · 2 participants
  • d

    dr.henry

    11/15/2017, 6:33 PM
    What would be the kotlin version of this? Runnable r = new Runnable() { @Override public void run() { while (mStatus) { synchronized (this) { try { wait(1000 * 60); } catch (Exception e) { e.printStackTrace(); continue; } } sendRequest(); } } }; thread = new Thread(r); thread.start();
    i
    j
    +2
    16 replies · 5 participants
  • e

    edwardwongtl

    11/16/2017, 6:00 AM
    val date
    and
    val source
    ?
    o
    g
    10 replies · 3 participants
Powered by Linen
Title
e

edwardwongtl

11/16/2017, 6:00 AM
val date
and
val source
?
o

oianmol

11/16/2017, 6:01 AM
i used var
abstract class Message { abstract var date: Long; abstract var source: MessageSource abstract var type: MessageType } data class TextMessage( override var date: Long = 0L, override var source: MessageSource = MessageSource.BOT, override var type: MessageType = MessageType.TEXT, var text: String ) : Message()
g

gildor

11/16/2017, 6:03 AM
TextMessage(text = "my text")
and should work already with your code
or just make first constructor argument and you can write
TextMessage("my text")
instead
o

oianmol

11/16/2017, 6:05 AM
have you tried ? it doesn't work. it asked me to add all the parameteres to the args
can you paste the way you have written your constructor
g

gildor

11/16/2017, 6:07 AM
Just copied your code and the first way works
o

oianmol

11/16/2017, 6:07 AM
thanks buddy it worked
TextMessage(text = "my text")
g

gildor

11/16/2017, 6:08 AM
second should work if text will be the first argument:
data class TextMessage(
        var text: String,
        override var date: Long = 0L,
        override var source: MessageSource = MessageSource.BOT,
        override var type: MessageType = MessageType.TEXT
) : Message()
Kotlin doesn’t allow to mix optional and non-optional arguments without explicit argument name, so better to put args with default values after other args
View count: 1