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

    Sergio C.

    12/02/2021, 6:50 PM
    A data class cannot extend another data class but it can extend a normal open class. I was expecting this wouldn't work. 🤨 Why not allow data class to extend another data class? What am I missing?
    z
    e
    j
    • 4
    • 5
  • a

    Ashu

    12/03/2021, 7:05 AM
    Shouldn't there be a function with following signature?
    StateFlow<T>.map(.....) : StateFlow<R>
    Since the mapping flow is a state flow it should already have an initial value right? Then why not just map it directly to a state flow? And if I wish to define such an extension function, how should I do that?
    a
    • 2
    • 2
  • m

    marlonlom

    12/06/2021, 2:21 AM
    Greetings, Question About android :android-10: design with xml: when using a CoordinatorLayout and, inside it, a FragmentContainerView and a BottomnavigationView, it shows that the layout appears empty and only the bottomNavigationView appears, is there any property of the coordinatorlayout or fragmentcontainerview that adjusts this mess? In the windows that are associated with the bottomNav, there is a NestedScrollView as the main component and a child of the ConstraintLayout
    :not-kotlin: 6
    j
    i
    • 3
    • 2
  • u

    uptoyou

    12/06/2021, 5:18 PM
    Does anyone used
    ktor-client-auth
    in KMM ? Is it suppose to work for Authentication Code Flow + PKCE on Android and iOS ?
    a
    c
    • 3
    • 3
  • c

    Colton Idle

    12/07/2021, 8:48 PM
    I'm using preferences datastore (sharedpref replacement) and it only seems to support a Flow and it doesn't support a synchrounous api. I have an app setting that has to be read super early in the app (basically it's the first thing that has to be read in the app for initialization). Is there an easy way to do this with datastore, or should I just look up how to convert a Flow into a synchronous single call?
    c
    f
    • 3
    • 7
  • r

    Ryan Flynn

    12/08/2021, 8:19 AM
    Hi all! I’m looking to call a REST API from an android app with coroutines. I could use some pointers to the best practices for how to call and propagate a JSON response from the api elsewhere in the application (business logic) which in turn will update the UI? Also, my more specific question is can I (and how) block the IO thread waiting for a synchronous HTTP request to return? How would I set this up from the caller? Thanks
    a
    j
    • 3
    • 2
  • s

    skwalking

    12/08/2021, 11:18 AM
    Am I missing something in my app made with Jetpack Compose? At start my app has a button to get URI with OpenDocumentTree() Then after getting uri to required directory, I do all the procedure like showing images, videos and doing operation such as saving and sharing. So in short: Button-> Get URI from OpenDocumentTree()-> Show Images and Videos, Do operations-> App closed-> Repeat... What I want: Once I got uri from OpenDocumentTree() I want to just load images & video from there. And provide a refresh button to just load newly added images or videos. But I think I'm missing some logic of some sort.
    :not-kotlin: 6
    c
    • 2
    • 1
  • l

    Lucca Beurmann

    12/08/2021, 11:59 PM
    Hello everyone, can anyone help me with an issue with hilt and modularised apps? So far my app has 3 modules: app (the default one), di and network. The idea here is putting hilt related dependencies in the DI module, so consumer modules can use this DI library without explicitly declaring the dependencies in the module's gradle file.
    :not-kotlin: 2
    • 1
    • 5
  • a

    Arpan Sarkar

    12/09/2021, 11:32 AM
    I am trying to run the epoxy (https://github.com/airbnb/epoxy) sample app but getting this error..how to resolve this? Java Version: OpenJDK Runtime Environment Temurin-11.0.12+7
    ava.lang.IllegalAccessError: class org.jetbrains.kotlin.kapt3.base.KaptContext (in unnamed module @0x75446cc6) cannot access class com.sun.tools.javac.util.Context (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.util to unnamed module @0x75446cc6
    	at org.jetbrains.kotlin.kapt3.base.KaptContext.<init>(KaptContext.kt:28)
    	at org.jetbrains.kotlin.kapt3.KaptContextForStubGeneration.<init>(KaptContextForStubGeneration.kt:40)
    	at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.contextForStubGeneration(Kapt3Extension.kt:287)
    	at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:171)
    	at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:102)
    	at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$invokeExtensionsOnAnalysisComplete(TopDownAnalyzerFacadeForJVM.kt:112)
    	at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:122)
    	at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:86)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:252)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:243)
    	at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:113)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:243)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:90)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:56)
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:169)
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
    	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:92)
    	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
    	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
    	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:412)
    	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:112)
    	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:358)
    	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally$default(IncrementalCompilerRunner.kt:300)
    	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl$rebuild(IncrementalCompilerRunner.kt:119)
    	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:170)
    	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:81)
    	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:607)
    	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:96)
    	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1658)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
    	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
    	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
    	at java.base/java.security.AccessController.doPrivileged(AccessController.java:691)
    	at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705)
    	at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
    	at java.base/java.lang.Thread.run(Thread.java:831)
    🧵 4
    t
    • 2
    • 1
  • d

    dave08

    12/09/2021, 1:56 PM
    Hi! Anybody could spot why the onSharedPreferenceListener is never called in the code in the thread?
    • 1
    • 1
  • m

    Micko Cabacungan

    12/09/2021, 6:08 PM
    not kotlin but I'm wondering if anyone else is having trouble downloading Android Studio from the download page for M1 Macs
    🇳🇴 1
    k
    j
    • 3
    • 5
  • j

    Joshua Akinsola

    12/09/2021, 7:23 PM
    Does anyone get a "Can't install" message for their android apps? Not sure what's causing this issue
    :not-kotlin: 2
    i
    • 2
    • 3
  • d

    Dariusz Rusin

    12/10/2021, 8:59 AM
    Hi. I’ve just updated app to Kotlin 1.6.0. Everything works except of Espresso tests:
    Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.compose.ui.platform.InfiniteAnimationPolicy$DefaultImpls" on path: DexPathList[[zip file "/system/framework/android.test.mock.jar", zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.xxx.test--U04pIcan0sKvbMH_f3aCQ==/base.apk", zip file "/data/app/com.xxx-MvGPQxMJ3GAEvifVyCdW8w==/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.test--U04pIcan0sKvbMH_f3aCQ==/lib/x86, /data/app/com.esky-MvGPQxMJ3GAEvifVyCdW8w==/lib/x86, /data/app/com.xxx.test--U04pIcan0sKvbMH_f3aCQ==/base.apk!/lib/x86, /data/app/com.xxx-MvGPQxMJ3GAEvifVyCdW8w==/base.apk!/lib/x86, /system/lib]]
    	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    	... 39 more
    I’m using latest versions of compose libs:
    1.1.0-beta04
    Any ideas?
    a
    i
    • 3
    • 4
  • i

    Illustrator

    12/11/2021, 8:46 AM
    hello guys, is there any good way of handling multiple load states in viewmodel using flows?
    a
    k
    a
    • 4
    • 3
  • u

    uptoyou

    12/14/2021, 10:37 AM
    Kotlin 1.6.10 released, but as of versions page there is no plugin for 2021.1.1 https://plugins.jetbrains.com/plugin/6954-kotlin/versions. Does it mean Android Studio Bumblebee will not receive it ?
    j
    • 2
    • 1
  • a

    AlmPazel

    12/15/2021, 3:50 AM
    nice illustration @Ameen Essa
    a
    • 2
    • 1
  • t

    Tower Guidev2

    12/15/2021, 9:42 AM
    Hi, im trying out
    loadStateFlow
    to manage my android activity load states and do not understand how to achieve the desired effect heres my code...
    • 1
    • 3
  • a

    ahmed qaisi

    12/15/2021, 12:25 PM
    Hello all , I have a problem in debug apk When QA team need to install my apk This alert appear What is problem ?
    :not-kotlin: 8
    m
    k
    +3
    • 6
    • 29
  • a

    Asad Mukhtar

    12/15/2021, 9:26 PM
    Hi, Everyone Can anyone please explain why we need SingleLiveEvent with example i didn`t understand, i have seen the same implementation working with MutableLiveData and SingleLiveEvent ?
    :not-kotlin: 2
    a
    n
    • 3
    • 11
  • e

    Erik

    12/15/2021, 11:17 PM
    In this commit (https://github.com/erikhuizinga/2021-12-16-developer.android.com-jetpack-guide-ui-layer-events/commit/9503f634bea5d9f6ab971c6a4814c1944bf9db4c) I'm trying to observe the state (
    StateFlow<State>
    ) in two fragments in the same activity. As can be seen in the logcat at runtime, only one of the two fragments receives new state values. I don't understand why, because a
    StateFlow
    should emit to all collectors, not just one. Why is that? What am I doing incorrectly?
    g
    j
    • 3
    • 34
  • h

    Honey Sandy

    12/17/2021, 8:28 AM
    I have cocoapods installed on my mac. Then i run kmm project in android studio i always get Cannot run program “pod”java.io.IOException: error=2, No such file or directory How can i resolve this? Thanks!
    a
    • 2
    • 1
  • a

    ahmed qaisi

    12/18/2021, 9:21 PM
    Can someone help me fully understand the problem?
    :not-kotlin: 8
    a
    j
    • 3
    • 5
  • o

    Orhan Tozan

    12/19/2021, 2:00 PM
    What Kotlin version will stop supporting kotlin-android-extensions / synthetics ?
    👀 3
    l
    e
    • 3
    • 3
  • p

    Pablo

    12/20/2021, 8:12 AM
    Anyone with basic knowledge about Firebase database (firestore) that can help me with one simple thing that I'm stuck? Will be less than 5 min for sure because I'm not used to use this db...
    :not-kotlin: 5
    c
    d
    • 3
    • 3
  • m

    Milan Vadhel

    12/21/2021, 12:47 PM
    Hello Friends, I am working with Ktlint custom ruleset . I have written one custom rule. When i try to execute that rule then it will execute successfully without any error, but it should show error. Here is my CustomRule class
    class CustomRule : Rule("FunctionNamingConvention") {
        override fun visit(
            node: ASTNode,
            autoCorrect: Boolean,
            emit: (offset: Int, errorMessage: String, canBeAutoCorrected: Boolean) -> Unit
        ) {
         
            if (node.elementType == VAR_KEYWORD) {
                emit(node.startOffset, "Unexpected var, use val instead", false)
            }
        }
    }
    Here is i have register that class.
    class CustomRuleSetProvider : RuleSetProvider {
        override fun get(): RuleSet {
            return RuleSet("FunctionNamingConvention", CustomRule())
        }
    }
    Any one have idea about this?
    a
    s
    • 3
    • 3
  • l

    Lucca Beurmann

    12/22/2021, 3:00 PM
    Hello everyone, can anyone help me with this test case?
    @Test
    fun `Should get images and add to list`() = runBlockingTest {
        coEvery { getPhotosUseCase(any()) } returns flow { emit(Source.Success(GetImagesTestData.DOMAIN_RESPONSE)) }
    
        //viewModel.getImages()
    
        coVerify(exactly = 1) { getPhotosUseCase(any()) }
        confirmVerified(getPhotosUseCase)
        assertEquals(GetImagesTestData.DOMAIN_RESPONSE, viewModel.photos.toList())
    }
    This test keeps failing because it says that viewModel.photos.ToList() is empty, therefore not equal to the expected result. The test will only pass if call the viewModel.getImages() method inside the test block, but this method is already being called in the init{} block of the viewModel. Can anyone help me understand why this is happening?
    j
    s
    • 3
    • 9
  • f

    Fırat

    12/23/2021, 5:33 AM
    Hello friends, there is a working project, but not a single commit has been made for 1 year. When I run it after 1 year, I get certain errors like java.lang.IndexOutOfBoundsException: Index: 0, Size: 0. The size of list is coming from server appears to be 0 What I want to know is is there a solution that I can do myself or it is a server related problem.
    r
    j
    h
    • 4
    • 4
  • r

    Rene Win

    12/23/2021, 8:01 AM
    Hello, i have on question regarding optional parameters: for example i have a method called
    fun foo(val a: Int = 0)
    is it possible to have some conditional calling of "foo" like?
    val dummyBoolean = true
    foo(if(dummyBoolean) 1 else <use default value>)
    a
    • 2
    • 3
  • n

    Niharika Arora

    12/23/2021, 9:51 AM
    Hey everyone, Anyone here working with Material You or have some experience with it? Need some help.
    f
    c
    • 3
    • 3
  • a

    André Thiele

    12/23/2021, 1:44 PM
    hello everyone, I am currently stuck because Hilt cannot provide my ViewModel. When running tests, the ViewModel gets constructed correctly using a manual constructor call and the tests pass correctly, so I assume its an error with my Hilt configuration. I am using Compose and the viewModel() method. It crashes at runtime with the following error message:
    m
    • 2
    • 6
Powered by Linen
Title
a

André Thiele

12/23/2021, 1:44 PM
hello everyone, I am currently stuck because Hilt cannot provide my ViewModel. When running tests, the ViewModel gets constructed correctly using a manual constructor call and the tests pass correctly, so I assume its an error with my Hilt configuration. I am using Compose and the viewModel() method. It crashes at runtime with the following error message:
Caused by: java.lang.InstantiationException: java.lang.Class<app.example.ui.screens.ExampleViewModel> has no zero argument constructor at java.lang.Class.newInstance(Native Method) at androidx.lifecycle.ViewModelProvider$NewInstanceFactory.create(ViewModelProvider.java:219) ... 199 more
My ViewModel looks like this:
@HiltViewModel
class ExampleViewModel @Inject constructor(
    private val exampleRepository: ExampleRepository
) : BaseViewModel<Action, State>() {
@Composable
fun ExampleScreen(viewModel: ExampleViewModel = viewModel()) {
m

Marek Defeciński

12/23/2021, 2:04 PM
like here they say you should use hiltViewModel extension
https://stackoverflow.com/a/68584960/551383
a

André Thiele

12/23/2021, 2:43 PM
i mean i don't necessarily want to scope it to the navgraph. the docs state the following: https://developer.android.com/jetpack/compose/libraries#hilt
View count: 4