Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CompositionLocal LocalLayoutDirection not present (1.2.0) #2

Closed
lucas-gio opened this issue Apr 24, 2022 · 2 comments
Closed

CompositionLocal LocalLayoutDirection not present (1.2.0) #2

lucas-gio opened this issue Apr 24, 2022 · 2 comments

Comments

@lucas-gio
Copy link

Adrielcafe, muito obrigado pelo seu trabalho.
Tenho o seguinte erro quando aplico o exemplo da home page do bonsái, a árvore animal e os ícones, mas não sei qual é o problema. No meu caso, é simplesmente um projeto novo compose desktop:

Exception in thread "main" java.lang.IllegalStateException: CompositionLocal LocalLayoutDirection not present
	at androidx.compose.ui.platform.CompositionLocalsKt.noLocalProvidedFor(CompositionLocals.kt:188)
	at androidx.compose.ui.platform.CompositionLocalsKt.access$noLocalProvidedFor(CompositionLocals.kt:1)
	at androidx.compose.ui.platform.CompositionLocalsKt$LocalLayoutDirection$1.invoke(CompositionLocals.kt:119)
	at androidx.compose.ui.platform.CompositionLocalsKt$LocalLayoutDirection$1.invoke(CompositionLocals.kt:118)
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
	at androidx.compose.runtime.LazyValueHolder.getCurrent(ValueHolders.kt:29)
	at androidx.compose.runtime.LazyValueHolder.getValue(ValueHolders.kt:31)
	at androidx.compose.runtime.ComposerImpl.resolveCompositionLocal(Composer.kt:1776)
	at androidx.compose.runtime.ComposerImpl.consume(Composer.kt:1746)
	at androidx.compose.foundation.lazy.LazyListKt.LazyList(LazyList.kt:310)
	at androidx.compose.foundation.lazy.LazyDslKt.LazyColumn(LazyDsl.kt:250)
	at cafe.adriel.bonsai.core.BonsaiKt.Bonsai(Bonsai.kt:92)
	at com.gioia.radio.MainKt.BonsaiExample(Main.kt:58)
	at com.gioia.radio.ComposableSingletons$MainKt$lambda-13$1.invoke(Main.kt:62)
	at com.gioia.radio.ComposableSingletons$MainKt$lambda-13$1.invoke(Main.kt:61)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:116)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
	at androidx.compose.ui.window.Application_desktopKt$application$1$1.invoke(Application.desktop.kt:116)
	at androidx.compose.ui.window.Application_desktopKt$application$1$1.invoke(Application.desktop.kt:115)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:116)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
	at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2$1$1.invoke(Application.desktop.kt:227)
	at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2$1$1.invoke(Application.desktop.kt:226)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
	at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2$1.invoke(Application.desktop.kt:222)
	at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2$1.invoke(Application.desktop.kt:220)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
	at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:72)
	at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:2582)
	at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:2571)
	at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:247)
	at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source)
	at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:2571)
	at androidx.compose.runtime.ComposerImpl.composeContent$runtime(Composer.kt:2522)
	at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:478)
	at androidx.compose.runtime.Recomposer.composeInitial$runtime(Recomposer.kt:748)
	at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:433)
	at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2.invokeSuspend(Application.desktop.kt:220)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Process finished with exit code 1

Meu código é o seguinte:

@Composable
private fun EmojiIcon(emoji: String) {
    Text(emoji)
}

@Composable
fun BonsaiExample() {
    val tree = Tree<String> {
        Branch("Mammalia") {
            Branch("Carnivora") {
                Branch("Canidae") {
                    Branch("Canis") {
                        Leaf("Wolf", customIcon = { EmojiIcon("🐺") })
                        Leaf("Dog", customIcon = { EmojiIcon("🐶") })
                    }
                }
                Branch("Felidae") {
                    Branch("Felis") {
                        Leaf("Cat", customIcon = { EmojiIcon("🐱") })
                    }
                    Branch("Panthera") {
                        Leaf("Lion", customIcon = { EmojiIcon("🦁") })
                    }
                }
            }
        }
    }

    Bonsai(tree)
}

fun main() = application{
    BonsaiExample()
}

Em build.gradle, além das outras coisas:
`plugins {
kotlin("jvm") version "1.5.31"
id("org.jetbrains.compose") version "1.0.0"
}
tasks.withType {
kotlinOptions.jvmTarget = "11"

}
`

Saludações.

@lucas-gio lucas-gio changed the title CompositionLocal LocalLayoutDirection not present CompositionLocal LocalLayoutDirection not present (1.2.0) Apr 24, 2022
@adrielcafe
Copy link
Owner

Hi!
Can you try with Kotlin 1.6.10 and Jetbrains Compose 1.1.1?

@lucas-gio
Copy link
Author

Sorry man, my bad.
I forgot to use Window() in this manner:
fun main() = application { BonsaiExample() }
but the correct is:
fun main() = application { Window(onCloseRequest = ::exitApplication) { BonsaiExample() } }

In addition, I increased the versions as you mentioned.

I only add that in a separate very empty project that I did, to verify this problem, I noticed that for this example it was necessary to add this dependency, otherwise i was getting this problem: java.lang.NoClassDefFoundError: androidx/compose/material/icons/filled/ChevronRightKt


var icons = "1.1.1"
implementation("org.jetbrains.compose.material:material-icons-extended-desktop:$icons")

Exitos!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants