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

    vipulkr210

    08/20/2017, 8:09 AM
    Holder.img = row!!.findViewById(R.id.img) as ImageView is showing error
    😵 3
    y
    d
    • 3
    • 2
  • r

    r-z

    08/20/2017, 7:31 PM
    I've got an async thread thing here and it stops prematurely without giving any errors if I edit the UI with it, any ideas what could be the cause? I'm not getting any errors
    :stackoverflow: 2
    k
    • 2
    • 4
  • v

    vedran

    08/21/2017, 6:07 AM
    @joe_androidsecurity you can "avoid" that itemView with
    with
    , example:
    class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        fun bind(item: Item) = with(itemView) {
            itemTitle.text = item.title
            itemSubtitle.text = item.subtitle
        }
    }
    👍 3
    j
    p
    • 3
    • 2
  • a

    adinugroho

    08/21/2017, 6:36 AM
    @joe_androidsecurity Have you implement from LayoutContainer ?
    j
    • 2
    • 4
  • m

    martynas

    08/21/2017, 7:22 AM
    Could anyone help me with an issue? My AS (2.3.3) can’t see any extension functions that are market
    @SinceKotlin("1.1")
    and shows compilation errors, but compilation succeeds without any problems. Anyone had and issue like that?
    j
    t
    • 3
    • 5
  • p

    peasee

    08/21/2017, 9:39 AM
    If you need a lot of logic to bind your view holder, where do people usually put it?
    d
    a
    • 3
    • 7
  • n

    neworldlt

    08/21/2017, 9:53 AM
    Do anyone know, if class is named
    xxx$1$1
    , will proguard require
    xxx$1
    class even
    xxx$1$1
    doesn’t depend on
    xxx$1
    ?
    d
    • 2
    • 14
  • t

    tapchicoma

    08/21/2017, 6:32 PM
    And what android plugin version are you using?
    y
    • 2
    • 4
  • j

    jkiefer

    08/21/2017, 7:44 PM
    Has anyone built a @StringDef in Kotlin and called it from Java yet? Having some weird lint issues
    d
    • 2
    • 3
  • s

    smuldr

    08/22/2017, 8:05 AM
    @yperess I just tried to upgrade to AGP 3.0.0-beta2, and I'm running into the same issue with using extension functions across modules. Also an extension on
    Context
    , by the way 🤔
    g
    y
    • 3
    • 6
  • s

    smilecs

    08/22/2017, 8:25 AM
    hi guys am going to ask another random question that seems important to me, I have been battling with the question of using retrofit or volley with kotlin and which would be better integrated especially in the point of mvp architecture so any insight or helpful advice on this?
    g
    s
    +2
    • 5
    • 6
  • r

    raghuramjampala

    08/22/2017, 12:16 PM
    So something like SampleObject sampleObject = new Gson().fromJson(sampleObjJson, SampleObject::class.java)
    k
    • 2
    • 6
  • a

    audhil

    08/22/2017, 12:44 PM
    code changes in kotlin files not getting reflected in app, but in java files. anyone faced and solved?
    my versions as follows
    kotlin.incremental=false in gradle.props file
    kotlin_version = '1.1.4-2'
    buildToolsVersion = "25.0.3"
        supportLibVersion = "25.3.1"
        archLifecycleVersion = "1.0.0-alpha1"
        archRoomVersion = "1.0.0-alpha1"
    
    Android Studio 2.3.3
    gradle  2.3.3
    wasted lot of time to overcome this issue, but could not succeed 😞
    k
    • 2
    • 5
  • r

    r-z

    08/22/2017, 2:06 PM
    I'm trying to figure out how to build a keyboard backspace like button. So short click for one symbol, hold for x ms for multiple remove symbol actions. Any ideas what kind of a listener should be used?
    :stackoverflow: 1
    y
    h
    • 3
    • 2
  • j

    juliocbcotta

    08/22/2017, 2:15 PM
    So… has anyone played with
    @Parcelize
    of kotlin 1.1.4 ? I can’t find a complete sample on Google… Kotlin blog has this
    @Parcelize
    class User(val firstName: String, val lastName: String) : Parcelable
    I could make the Parcelize import…but I could not make it compile…AS says I need to implement the Parcelable methods…
    y
    • 2
    • 1
  • p

    Paul Woitaschek

    08/22/2017, 10:05 PM
    The
    as?
    says that it will return null if it’s not the correct type
    h
    • 2
    • 1
  • u

    umasankar

    08/23/2017, 6:12 AM
    Hi guys, i tried to implement websocket in my kotlin based android project, but i didn't found any pretty clear tutorial for this, so could you please help me to find out any clear tutor or guidance.
    g
    • 2
    • 2
  • r

    robinchew

    08/23/2017, 8:02 AM
    Hey how do you render the
    Correct the following errors
    in

    https://storage.googleapis.com/material-design/publish/material_v_11/assets/0Bzhp5Z4wHba3dEZTUF9idzBHMWc/patterns_errors_userinput19.png▾

    ?
    g
    b
    • 3
    • 29
  • s

    sylcn

    08/23/2017, 8:35 AM
    Hi Guys 🙂 Is there any sample that shows how to we use arrayadapter viewholder pattern with kotlin ? I googled but every viewholder pattern related with recyclerviewadapter ? Thanks in advance
    g
    • 2
    • 1
  • s

    sylcn

    08/23/2017, 8:43 AM
    I want to use an arrayadapter in listview
    g
    b
    • 3
    • 9
  • j

    jw

    08/23/2017, 6:54 PM
    so copy over the 25 ones for now
    p
    • 2
    • 4
  • k

    kevinmost

    08/23/2017, 6:57 PM
    feels like we need a "don't ask Android questions in here if they have nothing to do with Kotlin" rule... or reaction-emoji or something
    l
    • 2
    • 1
  • a

    ankitdroiddeveloper

    08/25/2017, 6:17 AM
    Hi All. I have done a small project on Kotlin with Dagger2, RxKotlin and Retrofit2. Please have a look and feedback me. Url is https://github.com/AnkitDroidGit/Dagger2Retrofit2RxKotlinRxAndroidApplication
    👍 1
    b
    • 2
    • 1
  • d

    deviant

    08/25/2017, 6:41 AM
    does anyone expecting issues with AS3 b3? looks like i lost all my plugins 😞
    t
    • 2
    • 1
  • m

    matys

    08/25/2017, 10:53 AM
    Any idea why AndroidStudio is not downloading sources for my own library published to my own nexus? All the artifacts/sources are there and I can attach them manually, but for whatever reason AS cannot do it by itself. Or maybe I should include sources.jar inside AAR?
    k
    • 2
    • 1
  • g

    ghosalmartin

    08/25/2017, 11:13 AM
    When using Parcelable sealed classes, do I have to implement Parcelable to each subclass?
    k
    d
    • 3
    • 2
  • t

    trubesv

    08/26/2017, 7:20 PM
    message has been deleted
    e
    • 2
    • 1
  • b

    ben.slama.jihed

    08/27/2017, 11:55 AM
    hello , you can find here samle using ocr in kotlin : https://github.com/benslamajihed/android-vision-kotlin-sample
    r
    • 2
    • 1
  • r

    radityagumay

    08/27/2017, 12:13 PM
    I know, companion is equivalent with static, but you should not use like that. You can use join declaration. If you using kind like view utils, you should using extension function.
    o
    • 2
    • 1
  • b

    budioktaviyan

    08/28/2017, 10:36 AM
    It is throws an exception like this
    Only static methods can be annotated with @DeepLink
    g
    a
    • 3
    • 25
Powered by Linen
Title
b

budioktaviyan

08/28/2017, 10:36 AM
It is throws an exception like this
Only static methods can be annotated with @DeepLink
g

gildor

08/28/2017, 10:39 AM
@budioktaviyan Please, show your code. Probably you annotated class method with this annotation.
Try to annotate top level function or move function to companion object and add
@JvmStatic
annotation
b

budioktaviyan

08/28/2017, 10:41 AM
@DeepLink(SCHEME.plus(SERVICE_PAYMENT))
fun registerServiceDeepLink(context: Context): Intent {}
g

gildor

08/28/2017, 10:41 AM
Please show more code, it’s just a function declaration
b

budioktaviyan

08/28/2017, 10:41 AM
I just create this in my class, but suddenly it throws the exception. Previously it was Java class with static function
g

gildor

08/28/2017, 10:42 AM
As I said, if you need static method, you have two options, I mentioned them above
Kotlin has no static function, you should use top level function (function outside class) or function inside companion object with
@JvmStatic
annotation
b

budioktaviyan

08/28/2017, 10:43 AM
Yes, I ever do that but it is not working
wait, I will share the complete code
class DeepLinkDispatcher {

    companion object {
        const val SERVICE_PAYMENT = "payment"
        const val SCHEME = "myweb://"
        const val FLAGS_NEW_TASK = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP

        @DeepLink(SCHEME.plus(SERVICE_PAYMENT))
        @JvmStatic
        fun registerServiceDeepLink(context: Context): Intent {
            return Intent(context, clazz<PaymentHomeActivity>()).apply {
                putExtra(PaymentHomeActivity.HomeIntentKey.SOURCE, MyConstants.EventConstants.PROPERTY_VALUE_SOURCE_DEEP_LINK)
                action = DeepLinkKey.ACTION_DEEP_LINK_SERVICE
                flags = FLAGS_NEW_TASK
            }
        }
    }
}
g

gildor

08/28/2017, 10:49 AM
Oh, yeah, I see, probably it will not work, just because JvmStatic generates one more method, not replaced original one. Maybe better to use top level function
b

budioktaviyan

08/28/2017, 10:50 AM
I have been do this but it is not working for this lib 😄
hmmm ic
g

gildor

08/28/2017, 10:50 AM
I’m not sure about my previous statement, but probably it works this way
b

budioktaviyan

08/28/2017, 10:50 AM
let me try
g

gildor

08/28/2017, 10:51 AM
Anyway, top level functions is definetely static
b

budioktaviyan

08/28/2017, 10:52 AM
yeah, I know it :) .. cool its working now
g

gildor

08/28/2017, 10:53 AM
I’ve checked. Yes, @JvmStatic creates one more method for Java, that proxies call to Companion object, so this lib found also non-static version
Actually it’s interesting case, maybe you should create an issue about it, and someone would propose some solution also for such cases, but probably top level function is good workaround for all cases, I’m not sure
b

budioktaviyan

08/28/2017, 10:56 AM
yes, I will raised an issue on those lib ASAP 🙂
g

gildor

08/28/2017, 10:57 AM
Anyway, this lib does everything in correct way, but probably they could add some Kotlin workaround and docs
b

budioktaviyan

08/28/2017, 10:58 AM
and did you know ? this lib are really helpfull for create a simple deeplink in android hahaha
a

alex.hart

08/28/2017, 11:01 AM
This would make a great medium post, exploring the compile-time differences between @JVMStatic annotated methods and top-level methods.. because I can guarantee other people will be bitten by this (I learned something today!)
b

budioktaviyan

08/28/2017, 11:41 AM
Yes, me too, Just know it. Sometimes it can be a little bit different between top-level function and
@JVMStatic
hahahha
https://github.com/airbnb/DeepLinkDispatch/issues/193
View count: 2