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
stackoverflow
  • u

    user

    07/09/2022, 5:31 AM
    What is wrong with my Android Proguard rule I am using the Gson android library for handling data with a kotlin data class. Kotlin Data Class class DataType { data class UserData { var userName: String = ""; var userEmail: String = ""; } } Android Proguard Rule -keep class .DataType.* {*;} The problem is my application working fine in debug mode, but proguard obfuscated the code in release mode and the release version not working as expected. Any solution???
  • u

    user

    07/09/2022, 5:31 AM
    How to solve this Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE Have been trying to solve this but couldn't . this is udacity lesson where i am trying to create notifications using pending intent but there is problem with Pending Intent being Mutable i tried with this way ViewModel private val REQUEST_CODE = 0 private val TRIGGER_TIME = "TRIGGER_AT" private val minute: Long = 60_000L private val second: Long = 1_000L private val timerLengthOptions: IntArray private val notifyPendingIntent: PendingIntent private val alarmManager =...
  • u

    user

    07/09/2022, 5:51 AM
    value exist in sharedPreferences but cant get Kotlin Andriod I have a code with sharedPreferences file that contain LoggedInUsername. i am getting this data from firestore and put it into sharedPrefernce file. saad zahid but when i want to get that username nothing is shown. here is the code while putting the string into sharedPreference file: val sharedPreferences = activity.getSharedPreferences( Constants.ESHOPE_PREFERENCES, Context.MODE_PRIVATE ) val editor :...
  • u

    user

    07/09/2022, 6:31 AM
    How to select and display a live table with kotlin, room, mvvm? In my First fragment, I create the team name (corresponding to my team_table). Then, I move on to the fragment for adding player names. I would like to display directly and only the list of players corresponding to the team. It seems to work when I want to update a player's name and come back to that player list. Otherwise, it shows me the list of all the players of all the teams. How can I do, please? Here's my code: class UserViewModel(application: Application):...
  • u

    user

    07/09/2022, 6:31 AM
    Thrown exception is not caught properly, causing my app to crash I have these two functions override suspend fun getUser(loadUserImage: Boolean): BaseResult = withContext(realmWriteDispatcher) { getResult { RealmDb.useRealm { user()?.mapToUser() } } } private fun Realm.user(): RealmUser { findFirst()?.let { return it } sessionRepository.logout() loginNavigation.onLoggedOut() throw UserNotFoundException() } Basically anywhere in the app, you can fetch the...
  • u

    user

    07/09/2022, 7:31 AM
    Flutter App crash on launching showing some DexPathList error When I start my app its showing this error. I have change my package name but I don't get where this com.epixmobile.dor.DOR is coming I have change every where with com.epixmobile.dor but error is not going. java.lang.RuntimeException: Unable to instantiate application com.epixmobile.dor.DOR: java.lang.ClassNotFoundException: Didn't find class "com.epixmobile.dor.DOR" on path: DexPathList[[zip file...
  • u

    user

    07/09/2022, 8:31 AM
    Recyclerview to not update when activity containing it is opened? IS it possible for a recyclerview to not update when the activity is opened, but will update if reopened? db = FirebaseFirestore.getInstance() db.collection("Helpers") .whereEqualTo("helperReady", true) .whereEqualTo("state", "Online") .addSnapshotListener(object : EventListener { override fun onEvent(value: QuerySnapshot?, error: FirebaseFirestoreException?) { if (error != null) { Log.d("Firestore Error: ",...
  • u

    user

    07/09/2022, 9:11 AM
    I have tried searching everywhere,I am actually building an app in Android Studio and I am getting these errors, can someone please

    enter image description hereâ–¾

    This is the errors that is being shown every time I try to compile
  • u

    user

    07/09/2022, 9:31 AM
    Kotlin. Function does not exit recursion after return I need to decompose the number l into prime factors. For this I use recursion. And when l = 1, the function must exit their recursion and return the string in which the prime factors are located, however, the function continues to work and already according to a principle incomprehensible to me. Please explain what is the problem with my code? fun factors(l: Int): String { return if (l == 1) { answer } else { for (i in 2..l) { if (l % i == 0) {...
  • u

    user

    07/09/2022, 9:51 AM
    How can I run Nested Test in kotest? I'm trying to migrate test framework from JUnit 5 to kotest. I selected Annotation Spec at first (to check compatibility), but Nested Annotation doesn't work as expected Sample code is below class Outside : AnnotationSpec() { @Test fun runOutside() { } @Nested inner class Inside() { @Test fun runInside() { } } } runOutside runs well, but runInside doesn't. The error message is java.lang.IllegalArgumentException: object is not an instance of declaring...
  • u

    user

    07/09/2022, 11:11 AM
    how to correctly backup room database I read Backup Room database but I think answers contains errors for new releases of android studio and I want to know how to correctly backup and restore room database in 2022 in kotlin or java.
  • u

    user

    07/09/2022, 12:51 PM
    Lots of file are getting generated automatically in kotlin android *How to stop these files from getting generated ? so during commit they wont show up * when I change in any file then along with changed files lots of other files are getting generated which am totally unaware about. Some of the files are my class files but generated one are having $ or something after that . Check please some of files below . Most of these are not my class files. 1.androidResources 2.app-debug.apk 3.build-history.bin 4.buildOutputCleanUp.lock 5.call-attributes.tab...
  • u

    user

    07/09/2022, 12:51 PM
    Navigating between composable's using a Navigation Drawer in Jetpack Compose I am trying to set up navigation for the drawer icons/textfield in jetpack compose but not exactly sure how to do it properly. How can I set the navigation so that whenever I click in one of the Icons I get navigated to that composable screen? This is currently my MainDrawer layout: @Composable fun MainDrawer() { val scaffoldState = rememberScaffoldState() val scope = rememberCoroutineScope() Scaffold( scaffoldState = scaffoldState, topBar = {...
  • u

    user

    07/09/2022, 1:11 PM
    Firebase App check denied all queries for Firestore in Android Following the tutorial here but when firestore app check is enforced all queries come back as denied W/FirebaseProfileService: GET FAILED WITH com.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions. I have ran the app check in the main activity and it doesn't produce any errors. fun appCheck(){...
  • u

    user

    07/09/2022, 1:11 PM
    tun unit tests in parallel and other test sequentially in the same run spring boot kotlin i am having an issue to understand how can i run all the unit tests in my boot spring application(kotlin) in parallel while the springBootTests and the dataJpaTests will run one after the other(becouse they are failing due to shared context where running in parallel), my application structure is separated to different models and each model have it's unit,springBootTests and dataJpaTets, like this: -module 1: unit test 1 unit test 2 data jpa test 1 data jpa test 2 spring boot test1...
  • u

    user

    07/09/2022, 1:31 PM
    Model Class response issue I have a Model class data class OtpVerifyModel( val result: Int? = null, val msg: String? = null, val data: Datas? = null) in the response success stage, result is equal to 1 and we get Object in data where as if result is -1. we get string in data part. I used Datas class for data but app crashes in a case when data is a string. How can I handle two different type of data in same variable in different cases? here is my retrofit method @FormUrlEncoded @POST("Api/login") suspend fun...
  • u

    user

    07/09/2022, 1:31 PM
    Unable to build my android app in android studio and getting the following error Execution failed for task ':app:mergeDebugResources'. A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable Resource compilation failed. Check logs for details. Try: Run with --info or --debug option to get more log output. Run with --scan to get full insights. Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:mergeDebugResources'. at...
  • u

    user

    07/09/2022, 2:31 PM
    What is your way to come up the class name? I try to create a library with submodules. The main problem by now is class naming. I understand what the layout to be do, but cant give it name. For example, there is class ApiUntitled that contains property created from Retrofit Interface and no anything. How it can be name? class ApiUntitled(requestState: RequestState) { private val factory = ApiFactory(requestState) val playlist = factory.create(IPlaylistApi::class.java) val artist = factory.create(IArtistApi::class.java)...
  • u

    user

    07/09/2022, 2:31 PM
    Use JcaPEMWriter to export PEM file? I am trying to figure out how to export private key from the X509Certificate instance as a PEM string encoded. What I have done to far is to export certificate as PEM encoded: import org.bouncycastle.jce.provider.BouncyCastleProvider import org.bouncycastle.openssl.jcajce.JcaPEMWriter import java.io.StringWriter import java.security.KeyPairGenerator import java.security.Security import java.security.spec.ECGenParameterSpec fun main(args: Array) {...
  • u

    user

    07/09/2022, 3:11 PM
    Kotlin sealed class inheritance [Incompatible types, Type mismatch] I have declared a sealed class BaseEvent that contains a data class Event1 and sealed class EventImpl that inherits from BaseEvent and defines its own data class Event2. I want to check the parameter with the exhaustive when expression. Error: Incompatible types: BaseEvent.Event1 and EventImpl Type mismatch: inferred type is BaseEvent.Event1 but EventImpl was expected Code: sealed class BaseEvent { data class Event1(val value: String) : BaseEvent() } sealed class EventImpl : BaseEvent()...
  • u

    user

    07/09/2022, 3:11 PM
    Kotlin Annotation not present at Runtime I'm trying to use Kotlin Reflection to generate JFrames from Classes with their members. I have created a couple Annotations, some of them are present at runtime and some are not. Component Annotation: @Target(AnnotationTarget.FIELD, AnnotationTarget.PROPERTY) @Retention(AnnotationRetention.RUNTIME) annotation class Component(val constraints: String = "") IsEnabled Annotation: @Target(AnnotationTarget.FIELD, AnnotationTarget.PROPERTY) @Retention(AnnotationRetention.RUNTIME) annotation class...
  • u

    user

    07/09/2022, 4:11 PM
    Avoid going to String first when gzipping Is there a way of doing this gzip without first going to String and then back to ByteArray? suspend fun gzip(content: ByteArray): ByteArray = withContext(Dispatchers.IO) { ByteArrayOutputStream().apply { GZIPOutputStream(this).writer(UTF_8).use { it.write(String(content)) } }.toByteArray() } suspend fun ungzip(content: ByteArray): ByteArray = withContext(Dispatchers.IO) { GZIPInputStream(content.inputStream()).bufferedReader(UTF_8).use { it.readText() }.toByteArray() }...
  • u

    user

    07/09/2022, 4:31 PM
    XML text alignment Hellow i've a problem wiith my code, i don't know why te text isn't centered this is the code:

    the result photoâ–¾

    code photoâ–¾

  • u

    user

    07/09/2022, 4:31 PM
    json pars with retrofit in android kotlin hello i want parse Json with retrofit and use in recyclerview . I did this but ran into some problems The first problem :

    enter image description hereâ–¾

    The second problem :

    enter image description hereâ–¾

    Well, now you can see my files I think my problem is in the adapter file, but I don't know where it is Adapter.kt class Adapter(private val...
  • u

    user

    07/09/2022, 4:31 PM
    How to Inject field in an object module that provides - Hilt Android I have two classes on my android project: one is an object module and the other one is providing functions to be returned in the object module. Class 1: APIModule @Module @InstallIn(SingletonComponent::class) object APIModule { @Inject lateinit var db: FirestoreDB @Singleton @SandalItems @Provides fun provideCustomItems() = db.getCustomItems("sandals") @Singleton @ShoeItems @Provides fun provideCustomItems() = db.getCustomItems("shoes") ... }...
  • u

    user

    07/09/2022, 4:51 PM
    Integrating RecyclerView data with Fragment Android Studio Switching over code from main layout to Bottom Navigation which uses fragments. I've copied my code over underneath template code (see below) however no error codes when generated, but data does not show on app: package com.example.what2do_v6.ui.home import android.os.Bundle import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment import...
  • u

    user

    07/09/2022, 4:51 PM
    Moshi PolymorphicJsonAdapter can not make it to work I am quite new with android and Moshi and I am trying to make PolymorphicJsonAdapter to work Here is my setup for now: Retrofit: enum class TileContentType { @Json(name = "MediaTile") mediaTile, @Json(name = "QuestionTile") questionTile, @Json(name = "ConversationStarterTile") conversationStarterTile } @Provides fun provideRetrofit(okHttpClient: OkHttpClient, BASE_URL: String): Retrofit { val moshi = Moshi.Builder()...
  • u

    user

    07/09/2022, 5:51 PM
    How do I create this layout in Android? The list is a RecyclerView. How do I achieve the layout seen in the image?

    https://i.stack.imgur.com/buKt0.jpgâ–¾

  • u

    user

    07/09/2022, 6:31 PM
    What are the conditions when QuerySnapshot will give size zero even though there is document in Collection? [duplicate] I am trying to traverse through every documents in my newsfeeds Collection for getting data and add the data to a ArrayList. My each document in newsfeed contains two collections FeedNewsFeeds and FeedUserName ,which in their own contains documents. when I tried to get QuerySnapshot of newsfeeds collection ,i was unable, querySnapshot.size() always shows 0 . I have no idea how to handel this.

    https://i.stack.imgur.com/9NiSF.pngâ–¾

    <a...
  • u

    user

    07/09/2022, 7:11 PM
    Kotlin - Modify nested Data (Add item to List in an Object in another List in an Object) My User object has a List, each Post has a List. Now I would like to add a Tag item to the List. User: data class User( val id: String, val name: String, val posts: List = listOf() ) Post: data class Post( val id: Int, val name: String val tags: List = listOf() ) Now I would like to update my MutableStateFlow containing the User object: private val _userStateFlow: MutableStateFlow = MutableStateFlow(User()) val userStateFlow: StateFlow = _userStateFlow To find the...
Powered by Linen
Title
u

user

07/09/2022, 7:11 PM
Kotlin - Modify nested Data (Add item to List in an Object in another List in an Object) My User object has a List, each Post has a List. Now I would like to add a Tag item to the List. User: data class User( val id: String, val name: String, val posts: List = listOf() ) Post: data class Post( val id: Int, val name: String val tags: List = listOf() ) Now I would like to update my MutableStateFlow containing the User object: private val _userStateFlow: MutableStateFlow = MutableStateFlow(User()) val userStateFlow: StateFlow = _userStateFlow To find the...
View count: 1