https://kotlinlang.org logo
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

    Siddhant Mehta

    07/15/2020, 4:56 PM
    anyone knows any script/plugin where i can change android attribute value to my new value, like android:textColor:="my new value" everywhere in the app. #android-studio
    n
    • 2
    • 2
  • a

    allan.conda

    07/15/2020, 6:54 PM
    👋 Open question: At which point do you wrap kotlin exceptions into a sealed class / Either / exception wrapper? ViewModel, Interactor, Repository, DataSource, ASAP? I feel at least the exception shouldn’t reach the View layer.
    j
    b
    +2
    • 5
    • 7
  • s

    Sijan Rijal

    07/15/2020, 7:14 PM
    For a person who is just starting on reactive programming, could you drop in the replies on what you think are good resources to learn RxJava and RxKotlin?
    g
    s
    +2
    • 5
    • 4
  • s

    Steve

    07/15/2020, 11:04 PM
    I thought Android Studio used to have a refactoring to extract a method to a new class. Or does it, but can't do so in Kotlin?
    l
    • 2
    • 1
  • i

    Isaac Udy

    07/16/2020, 10:53 AM
    Hello! I'm a library author, and I'm looking to integrate with the new Dagger Hilt setup. One of the features of my library requires injection into an AndroidX ViewModel. Previously, I have provided this functionality through a custom ViewModelFactory, basically in the same way that AbstractSavedStateViewModelFactory works. I am having trouble figuring out how to do something similar for apps that are using Hilt. Is there a way to provide additional
    @Assisted
    injected parameters to a class that is using
    @ViewModelInject
    ?
    f
    • 2
    • 3
  • s

    Shreyas Patil

    07/16/2020, 3:57 PM
    I need help in this question about access modifier in Kotlin: https://stackoverflow.com/questions/62937511/how-to-hide-visibility-of-kotlin-internal-class-in-java?noredirect=1#comment111300497_62937511
    e
    • 2
    • 1
  • c

    Colton Idle

    07/17/2020, 2:05 AM
    Trying to reason about architecture,,, and even though I realize that fragments aren't the best thing out there, and AAC ViewModels aren't the best thing either... I think for a majority projects, there are a ton of benefits to just using what is provided to us from google. Knowing this I'm using a single LiveData to send my UiState to my View/Fragment and I observe the single state. This works really nicely in my opinion... what I still don't know how to do is how to send events from ViewModel to the Fragment via some kind of observable for Events. It seems like this library would be good enough for 98% of cases no? https://github.com/hadilq/LiveEvent
    l
    • 2
    • 1
  • s

    Slackbot

    07/17/2020, 5:29 AM
    This message was deleted.
    c
    r
    • 3
    • 2
  • a

    Alex Anisimov

    07/17/2020, 8:38 AM
    Hey everyone! May you please tell me what blogs and podcasts on Android/Kotlin development you follow and can recommend.
    g
    • 2
    • 1
  • s

    Sithuaungdev01

    07/17/2020, 10:21 AM
    Hi Everyone , I am an android developer from Myanmar. So glad to get a chance to join to this group. May you kindly please share about Kotlin new features and android tech. Is there any update with Kotlin compose ?
    a
    • 2
    • 1
  • t

    Tim Malseed

    07/18/2020, 7:52 AM
    Has anyone here got any experience debugging native crashes? I’ve got on occurring in production, which I cant reproduce. I’ve got what looks like a tombstone.. I’ve tried using the ndk tools ‘stack’ and ‘addr2line’ but they’re not giving me any additional information.. Stack just spits out basically the same output as the original dump, and addr2line can’t seem to locate the associated line number.
    • 1
    • 1
  • h

    Halil Ozercan

    07/18/2020, 1:07 PM
    Hello everyone, this is more of a personal question than a technical one. I've set a goal of improving myself in many aspects of Android Development in the next 12 months to increase my own marketability in the job market. I'm planning to explore most of Jetpack components including compose, how they play out with popular architectural patterns, in what ways Dagger(any dependency injection) should be utilized through out the application, how modular applications differ from traditional monolithic design, to learn details of both unit and UI testing, and etc. This seems a lot considering the time frame and most people would suggest focusing on one thing instead of being jack of all trades. That's why I'm confused and in need of help to figure out what to do. What are your suggestions for a "not so junior anymore" level of Android Developer who has decided to commit his next 5 years to Android Development? What kind of steps should I take today, that will benefit me after 12 months and also 5 years from now?
    g
    • 2
    • 1
  • j

    Jakekudur

    07/18/2020, 1:58 PM
    Hello everyone! If you have sample projects with MVVM, RxJava, Kotlin, Dagger 2 and Retrofit please share with me, for learning purpose🧐 😁. I want to master RxJava so I will be happy to see as much sample projects as you may share🤩
    e
    j
    • 3
    • 3
  • m

    Mike S

    07/20/2020, 2:00 AM
    Hello everyone, I want to fire off a REST API call with a Kotlin Coroutine from one fragment then handle the response in a different activity. Any recommendations? I feel like a broadcast receiver and service implementation is too heavy weight for what I'm trying to do.
    g
    j
    +2
    • 5
    • 13
  • s

    Sam

    07/20/2020, 5:49 AM
    Anyone have a problem like this when upgrade Android Gradle Plugin to 4x?
    com.android.tools.build:gradle:4.0.1 
    distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
    My error
    Could not resolve all dependencies for configuration ':app:stagingDebugRuntimeClasspath'.
    Could not create task ':app:packageProdDebug'.
    Could not get unknown property 'outputScope' for task ':app:packageProdDebug' of type com.android.build.gradle.tasks.PackageApplication.
    g
    • 2
    • 18
  • o

    Orhan Tozan

    07/20/2020, 11:07 AM
    Anyone familiar with https://github.com/dropbox/Store and willing to explain how it's meant to be used? I thought it was straight forward, until I couldn't find a way to get all the data? How should on do a
    getAll
    on the data in the store?
    n
    a
    t
    • 4
    • 17
  • j

    Joe Masilotti

    07/20/2020, 11:15 AM
    Does anyone have any insight on how I could build this radial selection in Android? This is a screenshot from the iOS app. I’m still pretty new to Android and I’m not even sure where to start Googling.

    https://files.slack.com/files-pri/T09229ZC6-F0175HQKE14/image.png▾

    j
    p
    +2
    • 5
    • 27
  • h

    hybridDeveloper

    07/20/2020, 11:39 AM
    Hello guys, Does any one have a sample MVI project with Coroutines/Flow or LiveData (Without RxJava) + DI
    :google: 1
    p
    • 2
    • 4
  • g

    Gabriel Feo

    07/20/2020, 5:09 PM
    Is there any
    @Parcelize
    equivalent for saving custom view state?
    c
    • 2
    • 3
  • v

    vinny2020

    07/20/2020, 6:54 PM
    instead of findViewbyId
    s
    • 2
    • 2
  • j

    ja.son

    07/21/2020, 12:18 AM
    @Madalin Valceleanu Nice to meet you! I was going to study with your project, but it's blocked in the execution part. Can I ask you a question?
    m
    • 2
    • 3
  • g

    Gabriel Feo

    07/21/2020, 2:02 AM
    Running into a strange issue with
    View.generateViewId()
    here with programatically created Views. It only outputs sequential IDs starting with
    1
    , and
    onRestoreInstanceState
    on these Views isn't called at all upon restore. Any ideas?
    s
    • 2
    • 5
  • c

    Chethan

    07/21/2020, 1:04 PM
    Hi , Is this going leak the memory , Shared view model concept - https://developer.android.com/topic/libraries/architecture/viewmodel#sharing Both fragments takes the reference of Activity View model , activityView model stay as long as activity stays . does it going to keep the sharedviewmodel reference once it is created till the point activity destroys ??
    j
    • 2
    • 12
  • n

    Nikola Milovic

    07/21/2020, 2:50 PM
    Is dynamic delivery a must know now? I am thinking of putting in the effort to get a good grasp on it, but I am not sure if it's a good idea to focus on that or just stay with the standard multi module approach.
    c
    • 2
    • 5
  • l

    Lilly

    07/21/2020, 3:59 PM
    Hi, I have a channel for offering packets:
    val responsePacketsChannel = ConflatedBroadcastChannel<ResponsePacket>()
    ResponsePacket is a interface because I have multiple packets which I want to offer, e.g.
    ParameterPacket: ResponsePacket
    or
    TimePacket: ResponsePacket
    . Now I'm wondering what would be the proper way to differentiate between the specific packets when I start to observe them. My first thought was using
    Pair<ResponsePacketType, ResponsePacket>
    combined with an enum
    ResponsePacketType
    ->
    val responsePacketsChannel = ConflatedBroadcastChannel<Pair<ResponsePacketType, ResponsePacket>>()
    Is there maybe a better solution?
    j
    z
    • 3
    • 5
  • c

    Christopher Elías

    07/21/2020, 5:28 PM
    Hello guys, If you are using coroutines in your Android Projects, this could probably help you to boost it https://blog.loop-ideas.com/android-livedata-coroutines-the-next-level-with-map-and-switchmap-extensions-b56a2f2f2ba7
    v
    • 2
    • 10
  • o

    Olenyov Kirill

    07/22/2020, 7:08 AM
    Hi. How can I zip two flows when each flow’s result is represented like sealed class? sealed class Response<out T> { object Loading ... data class Data<T>(val data: T)... data class Error(val error: Throwable)... } I see there is Flow.zip() operator but anyway it’s a lot of combinations and I have no idea how to cancel flow when one of the error received.. So, what’s the best Kotlin/Flow approach to deal with it?
    j
    m
    • 3
    • 7
  • s

    Sam

    07/23/2020, 2:05 AM
    Does anyone faced this problem? Its happen on MainActivity (MainScreen) I have research lots of solution but not work : https://stackoverflow.com/questions/28071349/the-specified-child-already-has-a-parent-you-must-call-removeview-on-the-chil Code: https://paste.gapo.vn/?cc82336a550e5d11#D6gYWyWvJCXRxAJWbHmWA77b8PPEB2hV95JABNgmyFhC
    <activity
        android:name=".view.MainActivity"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateAlwaysHidden" />
    Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
            at android.view.ViewGroup.addViewInner(ViewGroup.java:4915)
            at android.view.ViewGroup.addView(ViewGroup.java:4746)
            at androidx.viewpager.widget.ViewPager.addView(ViewPager.java:1485)
            at android.view.ViewGroup.addView(ViewGroup.java:4686)
            at android.view.ViewGroup.addView(ViewGroup.java:4659)
            at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:326)
            at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1199)
            at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1368)
            at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1446)
            at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1509)
            at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2637)
            at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2589)
            at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:247)
            at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:541)
            at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:201)
            at com.gg.gapo.view.MainActivity.onStart(MainActivity.kt:1213)
            at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1334)
            at android.app.Activity.performStart(Activity.java:6992)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2785)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2897) 
            at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4769) 
            at android.app.ActivityThread.-wrap18(Unknown Source:0) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1604) 
            at android.os.Handler.dispatchMessage(Handler.java:105) 
            at android.os.Looper.loop(Looper.java:251) 
            at android.app.ActivityThread.main(ActivityThread.java:6572) 
            at java.lang.reflect.Method.invoke(Native Method) 
            at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
    g
    • 2
    • 13
  • l

    lib

    07/23/2020, 3:22 AM
    大家好
    g
    • 2
    • 2
  • r

    rahul_lohra

    07/23/2020, 4:45 AM
    Hello, I needed some help in using
    java agent
    in Android, basically there is a
    premain function
    and I need this function to run before the Android's main function bus I was unsuccessful. So I am looking for some advice, what can go wrong? Also I am not getting anything on the log cat so it very difficult to debug The is the
    manifest
    of the jar
    Manifest-Version: 1.0
    Premain-Class: com.rahullohra.myagent.MyPremain
    Launcher-Agent-Class: com.rahullohra.myagent.MyPremain
    Boot-Class-Path: /home/rahulkumarlohra-xps/AndroidStudioProjects/Lab/m
     yagent/build/libs/myagent.jar
    In
    gradle.properties
    I have passed this jar as
    org.gradle.jvmargs=-javaagent:'/home/rahulkumarlohra-xps/AndroidStudioProjects/Lab/myagent/build/libs/myagent.jar'
    a
    j
    • 3
    • 9
Powered by Linen
Title
r

rahul_lohra

07/23/2020, 4:45 AM
Hello, I needed some help in using
java agent
in Android, basically there is a
premain function
and I need this function to run before the Android's main function bus I was unsuccessful. So I am looking for some advice, what can go wrong? Also I am not getting anything on the log cat so it very difficult to debug The is the
manifest
of the jar
Manifest-Version: 1.0
Premain-Class: com.rahullohra.myagent.MyPremain
Launcher-Agent-Class: com.rahullohra.myagent.MyPremain
Boot-Class-Path: /home/rahulkumarlohra-xps/AndroidStudioProjects/Lab/m
 yagent/build/libs/myagent.jar
In
gradle.properties
I have passed this jar as
org.gradle.jvmargs=-javaagent:'/home/rahulkumarlohra-xps/AndroidStudioProjects/Lab/myagent/build/libs/myagent.jar'
a

Adam Powell

07/23/2020, 1:32 PM
This doesn't exist in Android. Android app startup happens in a very different way. What are you trying to do? What code do you want to run before other app code at startup and why?
r

rahul_lohra

07/23/2020, 4:14 PM
Hi Adam, I want this feature to be available only for
DEBUG
variant TL;DR - I want to inject bytecode/java code some classes during compile time at specific places. I do not want to use any annotations. Full story: What I want & Why: - Two things First - I want to track our image loading performance in our app. Now assume my team is using Glide to load images and lot of people have already written code like below
Glide.with(context).load(url).into(imageView)
Now during
compile time I want to  attach listener
to above code and it will now look like this -
val glideListener = {....some logic...}
Glide.with(context).load(url).addListener(glideListener).into(imageView)
Now I know anyone will say that one should use a common class to load images, so that all the image loading calls will go through there and I totally agree with this. But I just want to explore what are the other possible ways to achieve this thing Second thing - I want to avoid exceptions. So I want to execute some instructions just before my actual content function will start to execute (This is very similar to aspectJ)
a

Adam Powell

07/23/2020, 5:17 PM
A pre-main is by definition runtime as opposed to compile time, you shouldn't need it if you are doing compile-time transformations.
If you do have runtime startup code you might find this useful: https://developer.android.com/topic/libraries/app-startup
but based on your description it sounds like this isn't really what you want either
r

rahul_lohra

07/23/2020, 7:23 PM
Thank you for correcting me Adam regarding compile-time transformations & compile-time transformations. 👍 And yes app-startup will not help me. Thanks to you, now at least I know where not to look.
For run-time class transformation - I think I should read on how the Android OS works and starts an application, I think from there I can get some hint For compile-time transformation - I think if I just write a simple script that will just modify the code the way I want. Then I can get what i want. Once again thanks a lot Adam👍
👍 1
j

Justin Tullgren

07/24/2020, 3:58 PM
Hi, I have a couple of suggestions if you want: 1. Use debug/release source sets. Pull the code you want to augment into a top level kotlin function. Declare it in both release and debug source sets but not in the main source set. In the debug add the listener/extra code. The release is the normal code. Then in main call the extracted top level function. 2. If you truly need byte code level you can use AOP byte code weaving using this plugin : https://github.com/Archinamon/android-gradle-aspectj and write aspects for your code in aspect j syntax, no annotations, where you can define your pointcuts. This happens at compile time in during the AGP transform step.
r

rahul_lohra

07/27/2020, 5:45 AM
Thanks Justin, I will try this library
View count: 6