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/02/2022, 1:31 PM
    Android Jetpack Compose Navigation doesn't work I'm making an android app using Jetpack Compose and I have a problem. I used navigation to change the screen. I wanted to change firstRunLayout to loginLayout. You can see that i put that log.d code in order to check if this worked and I found out that logcat prints that successfully. I want to change the screen when I navigate. Is there something wrong with my code? @Composable fun setUpNavHost(navController: NavHostController) { NavHost(navController = navController, startDestination =...
  • u

    user

    07/02/2022, 2:11 PM
    How do i add image picker on Android App? im triying to use an image picker so I can open the gallery and choose a pic for the user profile. Apparently the built-in image picker works only on Android 13 (API 33) so in order to add this feature i have to add this library. The first step is not clear to me: Gradle dependency: allprojects {...
  • u

    user

    07/02/2022, 2:11 PM
    How to make multiple inheritance in Kotlin with data class and interface? So i have very specific case. I have super class tile open class Tile(@Transient open val type: String, @Transient open val id: String) I have post tile that is currently Interface interface PostTile { val id: String val author: Author val createdDate: String var text: PostText? val topComment: Comment? val seeAllComments: DeeplinkAction? val tags: List? } And then all of my different type posts extends Tile and PostTile for example data class MediaTile(...
  • u

    user

    07/02/2022, 2:31 PM
    How does kotlin compiler know whether a val should be a property or a function The following kotlin code val nameHash get() = name.hashCode() can be compiled into java as follows public final int getNameHash() { return name.hashCode(); } and the property nameHash disapears. However when the val is changed to var, the compiler says "Property must be initialized" What is the deeper difference between var and val?
  • u

    user

    07/02/2022, 2:51 PM
    Kotlin Android One button works but other doesn't button1 is working perfectly fine but on clicking button, it crashes my app. Why is it happening? val button:Button=findViewById(R.id.signUp) val button1:Button=findViewById(R.id.logIn) button.setOnClickListener{ val intent1 = Intent(this,SignUpPage::class.java) startActivity(intent1) } button1.setOnClickListener { val intent2 = Intent(this,Welcome::class.java) startActivity(intent2) }
  • u

    user

    07/02/2022, 3:51 PM
    $ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspath' I am trying to make a Spotify clone app in Kotlin. I have not completed it yet but while checking whether it is running or not, i encountered with this error:- Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspath'. My App keeps crashing when i run it on the emulator I have tried the following solutions:- <a...
  • u

    user

    07/02/2022, 4:31 PM
    Coil: Loading indicator stacked on top of image instead of replacing image? I am loading a photo into a Image with Jetpack Compose and Coil. I want to show a loading indicator when image is loading, that replaces the picture while it loads. However I can't manage to figure it out and get it working properly. Problem with my code is that the loading indicator is loading on top of the image (and to left, bc i have not set center alignment, but it has the same behavior with center aligmnent, jsut that it is centered on top of the image). And it forces the textview down,...
  • u

    user

    07/02/2022, 5:31 PM
    Plugin [id: 'androidx.navigation.safeargs.kotlin'] was not found Today for functionalities in my Android App with navigation I should add plugin "androidx.navigation.safeargs.kotlin", but when gradle is syncing, I get an error: Build file 'C:\Users\capny\AndroidStudioProjects\VetDatabaseMobile\app\build.gradle' line: 7 Plugin [id: 'androidx.navigation.safeargs.kotlin'] was not found in any of the following sources: * Try:
    Run with --info or --debug option to get more log output.
    Run with --scan to get full insights.
    * Exception is:...
  • u

    user

    07/02/2022, 5:31 PM
    i tried to start a service ( playing music) from an activity but it is not working at all can anyone i am using kotlin below is my code i tried to start a service ( playing music) from an activity but it is not working at all can anyone i am using kotlin below is my code noting the service already added in the manifest file class MyService : Service() { lateinit var mediaPlayer:MediaPlayer override fun onCreate() { super.onCreate() Log.i("Service","service Created") mediaPlayer=MediaPlayer.create(this,R.raw.music2) } override fun onDestroy() { super.onDestroy() Log.i("Service","service Destroyed")...
  • u

    user

    07/02/2022, 5:31 PM
    An issue with App Open Ads in Kotlin | Android App Open Ads- I want to show ads with the first launch "onStart() function" but, The problem is that the Ads don't show in the first launch (onStart() function) it shows in the onResume() function after I exit the application and resume it. Are there any Suggestions or Editing Guys? MyApplication Class class MyApplication : Application() { private var appOpenManager: AppOpenManager? = null override fun onCreate() { super.onCreate() MobileAds.initialize(this) { Log.d("tag",...
  • u

    user

    07/02/2022, 6:31 PM
    How to provide context to firebaseManager using Hilt I would like to provide context to FirebaseManager.kt class FirebaseManager @Inject constructor( @ApplicationContext val context: Context, firebaseFirestore: FirebaseFirestore, firebaseStorage: FirebaseStorage ) { fun uploadImage(imageFileUri: Uri) { mProgressDialog = ProgressDialog(context) mProgressDialog.setMessage("Please wait, image being upload") mProgressDialog.show()
  • u

    user

    07/02/2022, 6:31 PM
    Safe-args: Passing an object from an imported package. Possible? I'm trying to pass a Track object from the GPX Parser package that I've imported. This is my navigation xml: I'm getting runtime exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mypackage.myapp/com.mypackage.myapp.MainActivity}: android.view.InflateException: Binary XML file line #10 in com.mypackage.myapp:layout/activity_main: Binary XML file line #10 in com.mypackage.myapp:layout/activity_main: Error inflating class...
  • u

    user

    07/02/2022, 7:11 PM
    Android - AlarmManager is not firing I'm trying to implement AlarmManager into my app so that a user can select the time and set an alarm for it, however, my AlarmManager does not seem to fire the alarm and trigger my BroadcastReceiver. Here's the code: MainActivity.kt package com.hussainaq.playground import android.app.AlarmManager import android.app.PendingIntent import android.content.Context import android.content.Intent import android.os.Build import android.os.Bundle import android.text.format.DateFormat import...
  • u

    user

    07/02/2022, 7:31 PM
    not finding a problem while successful installing apk but not working I am new at Android Studio. I created an App it build successfully not working on mobile phone. the App start just a blink and crashes. I am unable to find a problem Kindly suggest me a solution
  • u

    user

    07/02/2022, 7:51 PM
    Could not find com.theartofdev.edmodo:android-image-cropper:2.8.0 I add an image cropper in my application. But dispite using this guide, when I try to build the project, the following exception occurs: 10: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:mergeDebugNativeLibs'.
    Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
    > Could not find...
  • u

    user

    07/02/2022, 8:11 PM
    intent.putExtra getting too long and not convenient I am new using Kotlin and have implemented a recyvclerview list and now I'm using putExtra() and getStringExtra() intents to open in the same activities to avoid creating too many activities. So far it is working fine but I'm noticing my list is getting to long, and I'm planning on adding more. Is there a way to create a list of the numbers and call it into the intent? or maybe create another file class with the numbers and call it into the intent? If so how can it be done? val drinks =...
  • u

    user

    07/02/2022, 10:51 PM
    How to convert bitmap to file in kotlin using fragment? I want to get my image profile data. I have the bitmap, but the required type for image is MultipartBody How can I change bitmap to this type? Here's my code to load the image. I use fragment: private val cameraResult = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> if (result.resultCode == Activity.RESULT_OK && result.data != null) { val bitmap = result.data?.extras?.get("data") as Bitmap...
  • u

    user

    07/02/2022, 10:51 PM
    TextView onSelectionChanged function in Android Studio To be able to use onSelectionChanged function, I created a class which extends TextView class. The class is: public class DummyTextView extends TextView { public DummyTextView(Context context) { super(context); } public DummyTextView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } public DummyTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public DummyTextView(Context context, @Nullable...
  • u

    user

    07/02/2022, 11:51 PM
    FillMaxWidth does not take into account other elements in a Row - Jetpack compose

    https://i.stack.imgur.com/l58gG.png▾

    The Cardcontent composable is FillMaxWidth I want the "Cardcontent" composable to do fillMaxWidth inside the "Cardtest" composable taking into account the "Icon" composable
  • u

    user

    07/02/2022, 11:51 PM
    Google Places OpeningHours.getWeekdayText() is NULL for some locations I'm using google places to retrieve information for a place such as the business name, address, OpenHours and LatLng. This works 95% of the time, but for some places I receive the error... "Attempt to invoke virtual method 'java.util.List com.google.android.libraries.places.api.model.OpeningHours.getWeekdayText()' on a null object reference" Looking on Google maps, I do see these places have open hours information. //Add a marker when a POI on map is clicked....
  • u

    user

    07/03/2022, 12:31 AM
    How can mock repository.findAll().stream().map{}.filter{} I'm having trouble mocking my unit test. I can only mock findAll, but I am not able to mock findAll along with the other methods, stream, map and filter. What would the correct form of the syntax look like: whenever(productRerpository.findAll).thenReturn(product)? Below is my function inside the service class. fun getProductList(userId: Int?, filter: ProductBaseFilter): List { val productCompleteDtoList = productRepository.findAll() .stream() .map {...
  • u

    user

    07/03/2022, 3:11 AM
    How can I build rich text editor in Android studio like Contenteditable in HTML/JS? I am interested at Text-Editing app, so I am trying to build my own in Android Studio using available native solutions, like contenteditable in HTML. What I want to get is: Having a full control over the text field, e.g ‘input’ event like in DOM APIs. The content is fully customizable. I don’t want to use library or any dependencies.
  • u

    user

    07/03/2022, 3:31 AM
    Cannot find AGP version in build files &amp; empty Android Gradle Plugin Version

    empty AGP version▾

    Android Studio Upgrade Assistant recommends me to update Android Gradle Plugin from version 7.0.0. to x.x.x. However, the problem is that it alerts "Cannot find AGP version in build files". I'm struggling with this message and I found the empty AGP version in my project structure. I've already checked 'gradle-7.3-bin' inside 'C:\Users\abc.gradle\wrapper\dists' and allocated 'Gradle user home' as...
  • u

    user

    07/03/2022, 3:51 AM
    How to I get Intent to Join URI for my chromecast Android app I am developing an app for Chromecast But after registering Chromecast they want an Intent to Join URI to publish my app. How can I get this intent to URI, please... I'm new to this INTENT TO URI staff...

    enter image description here▾

  • u

    user

    07/03/2022, 6:11 AM
    viewmodel is runing multiple in compose i was checking my debug and i see my ViewModel or screen run multi time my viewModel @HiltViewModel class DownloadViewModel @Inject constructor( private val repository: DataRepository ): ViewModel() { val downloadList: LiveData = repository.getDownload().asLiveData() my screen @Composable fun TetsScreen(dm : DownloadViewModel){ Log.e("is running", "true") val downloads by dm.downloadList.observeAsState() Column(modifier = Modifier .background(color =...
  • u

    user

    07/03/2022, 6:11 AM
    Why there are two previews when creating custom components in android studio? see the below image:

    https://i.stack.imgur.com/DtH2O.png▾

    What is the use of another preview when they both look alike?
  • u

    user

    07/03/2022, 6:11 AM
    how to stop CountDownTimer in another Fragment? I have three fragment, A -> B -> C. I started CountDownTimer in A fragment and want to stop it in C fragment. please help me!
  • u

    user

    07/03/2022, 6:11 AM
    MutableStatOf Data Class not creating re-composition in Composable I am struggling to understand what is the best way to get this to work. I have some input fields and I created a TextFieldState to keep all the state in one place. But it is not triggering a re-composition of the composable so the state never updates. I saw this stack overflow answer on a similar question, but I just find it confusing and it doesn't make sense to me Here is the code: The Composable: @Composable fun AddTrip ( addTripVm: AddTripVm = hiltViewModel() ) { var name =...
  • u

    user

    07/03/2022, 6:31 AM
    how to assign a condition to an imageView by using if else? I tried to show a random imageView out of 2(one,two) with this binding.imageView.setImageResource(oneandtwo[random.nextInt(oneandtwo.size)]) it works fine and i wanted to increase score when i clicked on imageView but score increases independent to that, sometimes increases when i clicked on imageView2 and sometimes imageView, i want to increase score when i only clicked on imageView. i couldnt figure out. Thanks in advance. var score = 0 val oneandtwo: IntArray = intArrayOf(...
  • u

    user

    07/03/2022, 7:11 AM
    Type mismatch when creating state for Switch Even when I change the parameter isChecked type to MutableState another error is still returned. Type mismatch. Required: MutableState. Found: Boolean. @Composable fun PreferencesScreen(navController: NavController) { var isChecked = remember { mutableStateOf(false) } Scaffold( topBar = {...}, content = { LazyColumn(modifier = Modifier .padding(it) .fillMaxSize() ) { item {...
Powered by Linen
Title
u

user

07/03/2022, 7:11 AM
Type mismatch when creating state for Switch Even when I change the parameter isChecked type to MutableState another error is still returned. Type mismatch. Required: MutableState. Found: Boolean. @Composable fun PreferencesScreen(navController: NavController) { var isChecked = remember { mutableStateOf(false) } Scaffold( topBar = {...}, content = { LazyColumn(modifier = Modifier .padding(it) .fillMaxSize() ) { item {...
View count: 7