Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

149
Visualizações
Expected class has no actual declaration

I am doing a multiplatform project.

A part of my gradle file looks like this

...
kotlin {
    jvm()
    jvm("api")
    js()
    mingwX64("mingw")
    sourceSets {
        ...
        val jvmMain by getting {
            dependencies {
                implementation ("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
            }
        }
        val jvmTest by getting {
            dependencies {
                implementation ("org.jetbrains.kotlin:kotlin-test")
                implementation ("org.jetbrains.kotlin:kotlin-test-junit")
            }
        }
        val apiMain by getting {
            dependencies {
                dependsOn(jvmMain)
            }
        }
        val jsMain by getting {
            dependencies {
                implementation ("org.jetbrains.kotlin:kotlin-stdlib-js")
            }
        }
        ...
    }
}

Now in the commonsMain sources I get an IDE error (red underline) that says "expected class Sample has no actual declaration in apiMain", but apiMain depends on jvmMain which has the actual declaration.

I don't think I need an actual declaration in apiMain since I already have one in jvm.

Should I take a different approach in setting-up my source sets?

Anyway the project compiles fine and I can run apiMain, but the IDE error really annoys me.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

This is a known IDE bug. See YouTrack ticket here.

For now, you can use @Suppress("NO_ACTUAL_FOR_EXPECT") to get rid of the warning in your IDE. I wouldn't really recommend it though, because you'll get a runtime crash instead of a compile-time error if you're missing any actual implementations.

over 4 years ago · Santiago Trujillo Relatório

0

They should be under the same package name.

Also check if your package name is the same as the one you get the error

expected class Sample has no actual declaration in apiMain

You need to have the package apiMain.

In my case I had enter image description here And I had to create both folders in resources enter image description here

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda