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

    Fisayo

    05/14/2022, 8:06 AM
    Quick question about fragments (warning: I am a complete beginner). is it possible to perform multiple actions on a single fragment? For example, l've created fragments 1, 2, 3 and 4. Fragment 1 has one button which let's me navigate to fragment 2. Fragment 2 has two buttons, one is meant to allow me to return to Fragment 1 while the other is meant to take me to the next fragment (Fragment 3)...and Fragment 3 and 4 is similar to Fragment 2. I was able to move from Fragment 1 to 2. In Fragment 2, only one of the buttons worked correctly. The button that worked only allowed me to return to Fragment 1, however, every time I click on the button that's meant to take me to Fragment 3, my app crashes. My question is, are fragments only meant to allow one function per frame?......can one fragment not hold many functions e.g. having multiple buttons on one Fragment that does different things? All the videos I've seen online so far are only showing examples of - "One fragment, one function, one direction". Any feedback will be appreciated.
    :not-kotlin: 4
    v
    • 2
    • 1
  • s

    Slackbot

    05/14/2022, 10:47 AM
    This message was deleted.
    :not-kotlin: 1
    d
    c
    • 3
    • 8
  • b

    Breaker ACT

    05/14/2022, 3:26 PM
    Could you please to help me resolve this. I’m looking for a flow can adapt the requirement: Every single should be collect only one time, the value will be exist until it has been consumed and can be apply the filter. I’m have try with channel, but it have no function to filter value but keep it in the queue value if not match the conditional For example:
    val numberChannel = Channel<Int>(capacity = Channel.BUFFERED)
    GlobalScope.launch {
        numberChannel.send(0)
        numberChannel.send(1)
        numberChannel.send(2)
        numberChannel.send(3)
        numberChannel.send(4)
        numberChannel.send(5)
        numberChannel.send(6)
        numberChannel.send(7)
    }
    
    GlobalScope.launch {
        delay(1000)
        numberChannel.receiveAsFlow()
            .filter { it % 2 == 0 }
            .collectLatest {
                Timber.d("------Collect1: $it") //expect print: 0,2,4,6
            }
    }
    
    GlobalScope.launch {
        delay(2000)
        numberChannel.receiveAsFlow()
            .collectLatest {
                Timber.d("------Collect2: $it")  //expect print: 1,3,5,7
            }
    }
    🇳🇴 1
    e
    • 2
    • 3
  • s

    Slackbot

    05/15/2022, 6:34 PM
    This message was deleted.
    :not-kotlin: 4
    j
    o
    • 3
    • 2
  • y

    Yoshio Schermer

    05/16/2022, 2:25 PM
    Does anyone know here if stopping a staged release in the Play Console at say 10% and subsequently creating a new staged release for the same percentage, will ensure that the exact same group of users which were part of the 10%, get the update first? Or if this is not the right place to ask, where else could I (besides SO)?
    :not-kotlin: 5
    j
    k
    e
    • 4
    • 3
  • c

    Chukwuka Eze

    05/17/2022, 8:57 AM
    What does accessors mean in kotlin? Does it imply both getter & setter or it only means getter? Also, can anyone please explain this in the image below🙏
    r
    • 2
    • 2
  • v

    Vivek Modi

    05/17/2022, 9:18 AM
    Good Morning guys, What is the best approach to find three items in single list. I tried some code and working fine. I want to know is there any better approach for this
    val completeEvent = events?.lastOrNull { events -> events.status == "complete" }
    val activeEvent = events?.find { events -> events.status == "active" }
    val futureEvent = events?.firstOrNull { events -> events.status == "future" }
    ApiResponse
    "Events": [{
    			"title": "Test 1",
    			"status": "complete"
    		}, {
    			"title": "Test 2",
    			"status": "complete"
    		}, {
    			"title": "Test 3",
    			"status": "complete",
    		}, {
    			"title": "Test 4",
    			"status": "complete"
    		}, {
    			"title": "Test 5",
    			"status": "complete"
    		}, {
    			"title": "Test 6",
    			"status": "active"
    		}, {
    			"title": "Test 7",
    			"status": "future"
    		}, {
    			"title": "Test 8",
    			"status": "future"
    		}]
    g
    j
    • 3
    • 7
  • h

    haris mehmood

    05/18/2022, 9:52 AM
    Hi everyone, I want to run socket.io in background even app closed. One way is that start a foreground service but issue is that it display permanent notification to the user which is quite awkward. Thanks
    👈🏼 1
    👈 3
    :not-kotlin: 9
    a
    • 2
    • 1
  • v

    Vivek Modi

    05/18/2022, 9:41 PM
    Hey guys, anyone know any release site, in which I can find the android gradle version for intellij. I know latest intellij supports 7.0.4 in android-gradle. thanks
    :not-kotlin: 5
    n
    • 2
    • 1
  • a

    Aaron Waller

    05/19/2022, 6:28 PM
    Has anyone here experience with uploading images/files to the server using Retrofit or OkHttp? I’m wondering what is the best solution for that in 2022 using Kotlin. There are a lot answers on that in the internet but most of them are copying the content from the Uri to a File and then use this file to create the requestBody. But then there are also people like blackapps and commonware who commend under a lot of stackoverflow questions that it’s not recommended to work with Files when there is a Uri that can do everything. Here commonware explained how to create an InputStream RequestBody using the Uri in Kotlin: https://commonsware.com/blog/2020/07/05/multipart-upload-okttp-uri.html unfortunately this is not working for me: https://stackoverflow.com/questions/72307214/upload-image-from-uri-to-retrofit-s3-signed-url-not-working I really would love to know what you guys would do? What is the best approach in 2022 using Kotlin (and Jetpack compose)? Is copying the file to the internal storage and deleting it after upload still a good approach? It’s really difficult to find answers to that on Google, most solutions are written in Java and probably outdated. I also saw the approach of just calling .toFile() on that Uri but this seems to throw an error
    Error: java.lang.IllegalArgumentException: Uri lacks 'file' scheme: <content://media/external/images/media/54545>
    :not-kotlin: 2
    n
    f
    • 3
    • 2
  • k

    Kaushalya

    05/20/2022, 2:39 AM
    Anyone here using Kotlin DSL over Groovy here? Has build performance of Kotlin DSL improved?
    l
    c
    g
    • 4
    • 3
  • s

    Satyam G

    05/20/2022, 9:52 AM
    object Extensions{
        
        fun TextUtils.checkEmpty(str: String?): String? {
            if (!TextUtils.isEmpty(str)) {
                return str
            } else {
                return null
            }
        }
        
    }
    I have written this but not able to access this method. What is getting wrong here ??
    m
    e
    • 3
    • 2
  • c

    Chetak Bhimani

    05/20/2022, 9:57 AM
    try
    fun String.checkEmpty(str: String?): String? {
        if (!TextUtils.isEmpty(str)) {
            return str
        } else {
            return null
        }
    }
    s
    • 2
    • 1
  • i

    Iqbal Ahmed

    05/20/2022, 10:49 AM
    Hi Guys, Needed help to figure out the issue, I have updated Android Studio to chipmunk after that I am getting this Kotlin DSL issues in kotlin scripts. it’s compiling and building with no issues,
    t
    c
    • 3
    • 5
  • m

    manju reddy

    05/20/2022, 4:55 PM
    Hello All, will this channel also has Jetpack Compose support ?
    s
    • 2
    • 1
  • l

    lam bui

    05/22/2022, 4:37 AM
    I see many users, but I don’t understand the benefits of Either. What is the difference between Either and Pair in kotlin? https://arrow-kt.io/docs/apidocs/arrow-core/arrow.core/-either/.
    d
    e
    • 3
    • 4
  • n

    Nicolai

    05/24/2022, 3:53 PM
    Hi folks! 👋 Imagine a list A
    [{id: 1, isSomething: false},{id: 2, isSomething: false}]
    and list B
    [{id: 1, isSomething: true}]
    Is there an easy nice clean way in kotlin to merge the two lists so it ends up favoring list B ending up giving me
    {id: 1, isSomething: true},{id: 2, isSomething: false}]
    :not-kotlin: 1
    :kotlinnew: 1
    e
    • 2
    • 2
  • b

    Bhumil

    05/24/2022, 11:21 PM
    Hi Folks, Have anyone got experience with accessing/listening the Android’s Unit & Instrumented tests created with JUnit4 framework in Real-time? I have tried the approach of using custom runner but it needs to be specified as annotation in tests which is not what I prefer to do, also it doesn't work well with Instrumented tests.
    :not-kotlin: 2
    d
    • 2
    • 2
  • m

    Michaeljon Hayden

    05/25/2022, 4:11 PM
    Has anyone experienced a missing MainDispatcher only manifesting in release builds distributed via google play?
    :yes: 1
    :kotlin: 1
    :not-kotlin: 1
    j
    l
    g
    • 4
    • 6
  • r

    Raed Ghazal

    05/26/2022, 3:38 PM
    Hi, shouldn’t this be allowed? _*screenshot_1*_ using the same generic type works _*screenshot_2*_ just fine, but using a child generic type doesn’t and throws an error anyone got an idea of how to fix it? or another way of perform something like this?
    m
    e
    • 3
    • 23
  • s

    Susheel

    05/26/2022, 5:46 PM
    I'm seeing a compilation issue for
    Task :*****App:compileGoogleReleaseKotlin FAILED
    Unresolved reference: viewModels
    This is the
    by viewModels()
    code. The debug build compiles successfully, so I'm perplexed by the release build issue. Any ideas?
    :not-kotlin: 3
    • 1
    • 1
  • t

    TarunY

    05/27/2022, 9:48 AM
    HI Guys, can you please suggest how to solve below error.
    h
    • 2
    • 2
  • l

    Lucas Mo

    05/27/2022, 1:48 PM
    Hey guys. Is this channel adequate for questions about Gradle?
    :not-kotlin: 2
    a
    • 2
    • 2
  • a

    azabost

    05/27/2022, 6:55 PM
    Hey. I noticed something really strange today. I’m not sure but it might be somehow related with macOS 12.4 update or Kotlin 1.6.21 update I made recently. Whenever I change the code in my project (e.g. a log message) and use “Run” option in Android Studio (Bumblebee but Chipmunk didn’t help), the change I made is not reflected in the app. It works when I run
    ./gradlew :app:installDebug
    though, so I thought that it might be related with Gradle’s file system watching not working correctly (I’m on 7.4.2), therefore I disabled it in
    gradle.properties
    but it didn’t help at all. Any clues? EDIT: How is this “not Kotlin”? Perhaps it’s a problem with the Kotlin compiler/plugin not recompiling the sources after they are changed?
    :not-kotlin: 2
    c
    • 2
    • 2
  • l

    Lilly

    05/28/2022, 10:16 PM
    Is there a
    @IntRange
    annotation for kotlin which I can use in kotlin only module? @IntRange works at compilation time right?
    e
    c
    • 3
    • 8
  • f

    fulstaph

    05/29/2022, 5:29 PM
    hello! does anyone know how to add ktor backend module to android+ios multiplatform project (the one that android studio generates)? any help appreciated, thanks
    c
    • 2
    • 2
  • r

    Rene Win

    05/31/2022, 9:15 AM
    I have some conversion of a hex string into a UByteArray via:
    val test = chunked(2)
            .map { it.toInt(16).toUByte() }
        val test2: UByteArray = test.toUByteArray()
    when i debug those values, the test is an arrayList of UByte (correct), but the test2 value shows in the debugger thats an byte[] instead of ubyte[]. is that just an bug in the debugger because its experimental? i cannot find an answer somewhere
    e
    • 2
    • 1
  • l

    Lilly

    05/31/2022, 11:22 AM
    I have written a
    whenNotNull
    function:
    inline fun <T : Any, R> whenNotNull(input: T?, callback: (T) -> R): R? = input?.let(callback)
    
    usage:
    
    override fun onReceive(context: Context?, intent: Intent?) {
      whenNotNull(intent) {
        it.someAction()
      }
    }
    I have often problems with shadowed variable names, e.g. I cannot write:
    override fun onReceive(context: Context?, intent: Intent?) {
      whenNotNull(intent) { intent -> // shadowed
        intent.someAction()
      }
    }
    Is there some construct to recognize that
    intent
    is not null within the
    callback
    block, so I can write:
    override fun onReceive(context: Context?, intent: Intent?) {
      whenNotNull(intent) {
        intent.someAction()
      }
    }
    I have enabled some static analyzer tools which complain about the "it". I know I can just write
    whenNotNull(intent) { _intent -> }
    but I'm curious if there is some Kotlin construct which targets this case.
    l
    e
    • 3
    • 8
  • l

    Louis Gautier

    05/31/2022, 7:01 PM
    Hello. I’m trying to combine multiple objects into one
    fun <A, B>LiveData<A>.combine(
        vararg other: LiveData<*>,
        combiner: (/*Don't know*/) -> B
    ) {
        val result = MediatorLiveData<B>()
        other.forEach { liveData ->
            result.addSource(liveData) { 
                if (other.toList().all { it.value != null }) {
                    result.postValue(combiner(other))
                }
            }
        }
    }
    usage :
    fun a() {
        MutableLiveData<Int>().combine2(MutableLiveData<Boolean>()) { entry1, entry2, etc ->
            
        }
    }
    Do you have any ideas ?
    s
    f
    +2
    • 5
    • 9
  • p

    Philipp Smorygo [JB]

    05/31/2022, 10:07 PM
    Hi. I have some problem with Jetpack Compose in a Kotlin MPP project. Here is my gradle file for android application:
    plugins {
        kotlin("multiplatform")
        id("com.android.application")
    }
    
    group = "me.user"
    version = "1.0-SNAPSHOT"
    
    kotlin {
        android()
        sourceSets {
            val androidMain by getting {
                dependencies {
                    val compose_version = "1.2.0-beta02"
                    implementation(project(":shared"))
                    implementation("androidx.core:core-ktx:1.7.0")
                    implementation("androidx.compose.ui:ui:$compose_version")
                    implementation("androidx.compose.runtime:runtime:$compose_version")
                    implementation("androidx.compose.ui:ui-tooling:$compose_version")
                    implementation("androidx.compose.foundation:foundation:$compose_version")
                    implementation("androidx.compose.ui:ui-tooling-preview:$compose_version")
                    implementation("androidx.compose.material:material:$compose_version")
                    implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.1")
                    implementation("androidx.activity:activity-compose:1.4.0")
                    implementation("com.google.android.material:material:1.5.0")
                    implementation("androidx.appcompat:appcompat:1.4.1")
                    implementation("androidx.constraintlayout:constraintlayout:2.1.3")
                }
            }
        }
    }
    
    tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }
    
    android {
        compileSdkVersion(32)
        defaultConfig {
            applicationId = "me.user.androidApp"
            minSdkVersion(24)
            targetSdkVersion(32)
            versionCode = 1
            versionName = "1.0"
        }
        compileOptions {
            sourceCompatibility = JavaVersion.VERSION_1_8
            targetCompatibility = JavaVersion.VERSION_1_8
        }
        buildTypes {
            getByName("release") {
                isMinifyEnabled = false
            }
        }
        buildFeatures {
            compose = true
        }
        composeOptions {
            kotlinCompilerExtensionVersion = "1.2.0-beta02"
        }
    }
    But the problem is that application fails to build with
    Caused by: java.lang.IllegalStateException: couldn't find inline method Landroidx/compose/runtime/ComposablesKt;.remember(Lkotlin/jvm/functions/Function0;)Ljava/lang/Object;
    	at org.jetbrains.kotlin.codegen.inline.SourceCompilerForInlineKt.getMethodNode(SourceCompilerForInline.kt:118)
    	at org.jetbrains.kotlin.codegen.inline.SourceCompilerForInlineKt.loadCompiledInlineFunction(SourceCompilerForInline.kt:96)
    	at org.jetbrains.kotlin.backend.jvm.codegen.IrSourceCompilerForInline.compileInlineFunction(IrSourceCompilerForInline.kt:90)
    	at org.jetbrains.kotlin.codegen.inline.InlineCodegen.performInline(InlineCodegen.kt:47)
    	... 67 more
    Kotlin is 1.6.21 AGP version 7.2.1 I have
    buildFeatures {
            compose = true
        }
        composeOptions {
            kotlinCompilerExtensionVersion = "1.2.0-beta02"
        }
    In my
    shared
    module as well (edited)
    e
    • 2
    • 4
Powered by Linen
Title
p

Philipp Smorygo [JB]

05/31/2022, 10:07 PM
Hi. I have some problem with Jetpack Compose in a Kotlin MPP project. Here is my gradle file for android application:
plugins {
    kotlin("multiplatform")
    id("com.android.application")
}

group = "me.user"
version = "1.0-SNAPSHOT"

kotlin {
    android()
    sourceSets {
        val androidMain by getting {
            dependencies {
                val compose_version = "1.2.0-beta02"
                implementation(project(":shared"))
                implementation("androidx.core:core-ktx:1.7.0")
                implementation("androidx.compose.ui:ui:$compose_version")
                implementation("androidx.compose.runtime:runtime:$compose_version")
                implementation("androidx.compose.ui:ui-tooling:$compose_version")
                implementation("androidx.compose.foundation:foundation:$compose_version")
                implementation("androidx.compose.ui:ui-tooling-preview:$compose_version")
                implementation("androidx.compose.material:material:$compose_version")
                implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.1")
                implementation("androidx.activity:activity-compose:1.4.0")
                implementation("com.google.android.material:material:1.5.0")
                implementation("androidx.appcompat:appcompat:1.4.1")
                implementation("androidx.constraintlayout:constraintlayout:2.1.3")
            }
        }
    }
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

android {
    compileSdkVersion(32)
    defaultConfig {
        applicationId = "me.user.androidApp"
        minSdkVersion(24)
        targetSdkVersion(32)
        versionCode = 1
        versionName = "1.0"
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    buildTypes {
        getByName("release") {
            isMinifyEnabled = false
        }
    }
    buildFeatures {
        compose = true
    }
    composeOptions {
        kotlinCompilerExtensionVersion = "1.2.0-beta02"
    }
}
But the problem is that application fails to build with
Caused by: java.lang.IllegalStateException: couldn't find inline method Landroidx/compose/runtime/ComposablesKt;.remember(Lkotlin/jvm/functions/Function0;)Ljava/lang/Object;
	at org.jetbrains.kotlin.codegen.inline.SourceCompilerForInlineKt.getMethodNode(SourceCompilerForInline.kt:118)
	at org.jetbrains.kotlin.codegen.inline.SourceCompilerForInlineKt.loadCompiledInlineFunction(SourceCompilerForInline.kt:96)
	at org.jetbrains.kotlin.backend.jvm.codegen.IrSourceCompilerForInline.compileInlineFunction(IrSourceCompilerForInline.kt:90)
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen.performInline(InlineCodegen.kt:47)
	... 67 more
Kotlin is 1.6.21 AGP version 7.2.1 I have
buildFeatures {
        compose = true
    }
    composeOptions {
        kotlinCompilerExtensionVersion = "1.2.0-beta02"
    }
In my
shared
module as well (edited)
e

ephemient

06/01/2022, 1:06 AM
you need to enable the compose compiler plugin in your application build as well
I'm not sure if the android plugin works with mpp though
have you tried making it a plain android application module (no mpp)?
p

Philipp Smorygo [JB]

06/01/2022, 9:30 AM
Yes, everything works in android without MPP. It turns out to be a known issue. https://youtrack.jetbrains.com/issue/KT-38694 Here is a workaround to make compose work with mpp https://github.com/avdim/compose_mpp_workaround
View count: 3