androidMain and android tests folder not recognised as module

Hello, I’ve been struggling with this issue since days but can’t find any solution so I hope I can get any help here.
I created a Multiplatform project with Mobile Application template from IntelliJ IDEA 2020.2.1 and since project setup androidMain and AndroidTest folders are not recognised as module. This seems not to be a problem when launching androidApp task or PackForXcode as references to expect/actual definitions are resolved but idea suggestions shows anyway how androidMain reference seems to be wrong as reference seems to be resolved from parent vpayConnectLib module as per screenshot.

I use a standard android() target

When launching compileDebugAndroidTestKotlinAndroid task this error is highlighted

I tried to create new projects with different templates but androidMain and androidTest folders are not considered module since the beginning with all projects template

Is this a know bug or I am doing something wrong? Here’s root project gradle file with versions I am using

Any help is appreciated,
Thanks

Yeah when going multiplatform, the android sources have to deal with the android plugin and IntelliJ do not shows up the module. I normally go for this little workaround to align the android sources with the Kotlin/Multiplatform ones.

thanks for your response! Could you give me more insights on that workaround? Those folders are for Android app or Android Multiplatform code? Also I don’t see any folders for Test, how do you handle that?

I am travelling and driving. Later I’ll give you a hint!

thanks!
I add also my gradle files that may be useful.
Here’s my root project gradle file:

buildscript {
repositories {
gradlePluginPortal()
jcenter()
google()
mavenCentral()
}
dependencies {
classpath(“org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0”)
classpath(“com.android.tools.build:gradle:4.0.1”)
classpath(“com.squareup.sqldelight:gradle-plugin:1.4.3”)
classpath(“org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.8”)
}
}

group = “com.retailinmotion”
version = “1.0-SNAPSHOT”

repositories {
mavenCentral()
}

and my shared library gradle file:

import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

plugins {
kotlin(“multiplatform”)
id(“com.android.library”)
id(“kotlin-android-extensions”)
id(“com.squareup.sqldelight”)
id(“org.sonarqube”)
jacoco
}
group = “com.retailinmotion”
version = “1.0-SNAPSHOT”

repositories {
gradlePluginPortal()
google()
jcenter()
mavenCentral()
}

sqldelight {
database(“vPayConnectDatabase”) {
packageName = “com.retailinmotion.vpayconnect”
sourceFolders = listOf(“sqldelight”)
}
}

task(“jacocoTestReport”) {
dependsOn(“testDebugUnitTest”)
reports {
xml.isEnabled = true
csv.isEnabled = false
html.isEnabled = true
}
sourceDirectories.setFrom(files(fileTree("…/vPayConnectLib")))
classDirectories.setFrom(files(fileTree(“build/tmp/kotlin-classes/debug”)))
executionData.setFrom(file(“build/jacoco/testDebugUnitTest.exec”))
}

sonarqube {
properties {
property(“sonar.sourceEncoding”, “UTF-8”)
property(“sonar.java.coveragePlugin”, “jacoco”)
property(“sonar.sources”, “src/commonMain/kotlin, src/iosMain/kotlin, src/androidMain/kotlin”)
property(“sonar.tests”, “src/commonTest/kotlin, src/iosTest/kotlin, src/androidTest/kotlin”)
property(“sonar.binaries”, “build/tmp/kotlin-classes/debug”)
property(“sonar.java.binaries”, “build/tmp/kotlin-classes/debug”)
property(“sonar.java.test.binaries”, “build/tmp/kotlin-classes/debugUnitTest”)
property(“sonar.junit.reportPaths”, “build/test-results/testDebugUnitTest”)
property(“sonar.jacoco.reportPaths”, “build/jacoco/testDebugUnitTest.exec”)
property(“sonar.coverage.jacoco.xmlReportPaths”, “build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml”)
}
}

kotlin {

android()

iosArm64("ios") {
    binaries {
        framework {
            baseName = "vPayConnectLib"
        }
    }
    compilations["main"].cinterops {
        //import Datecs library
        val datecs by creating {
            packageName ("com.retailinmotion.datecs")
            defFile = file("$projectDir/src/iosMain/c_interop/Datecs.def")
            includeDirs ("$projectDir/src/iosMain/c_interop/Datecs/")
        }
        //import Datecs Utils library
        val datecsutils by creating {
            packageName ("com.retailinmotion.datecsutils")
            defFile = file("$projectDir/src/iosMain/c_interop/DatecsUtils.def")
            includeDirs ("$projectDir/src/iosMain/c_interop/DatecsUtils/")
        }
        //import Magtek library
        val magtek by creating {
            packageName ("com.retailinmotion.magtek")
            defFile = file("$projectDir/src/iosMain/c_interop/Magtek.def")
            includeDirs ("$projectDir/src/iosMain/c_interop/Magtek")
        }
    }
}

iosX64(){
    binaries {
        framework {
            baseName = "vPayConnectLib"
        }
    }
    compilations["main"].cinterops {
        //import Datecs library
        val datecs by creating {
            packageName ("com.retailinmotion.datecs")
            defFile = file("$projectDir/src/iosMain/c_interop/Datecs.def")
            includeDirs ("$projectDir/src/iosMain/c_interop/Datecs/")
        }
        //import Datecs Utils library
        val datecsutils by creating {
            packageName ("com.retailinmotion.datecsutils")
            defFile = file("$projectDir/src/iosMain/c_interop/DatecsUtils.def")
            includeDirs ("$projectDir/src/iosMain/c_interop/DatecsUtils/")
        }
        //import Magtek library
        val magtek by creating {
            packageName ("com.retailinmotion.magtek")
            defFile = file("$projectDir/src/iosMain/c_interop/Magtek.def")
            includeDirs ("$projectDir/src/iosMain/c_interop/Magtek")
        }
    }
}

sourceSets {

    val commonMain by getting {
        dependencies {
            implementation("com.squareup.sqldelight:runtime:1.4.3")
        }
    }

    val commonTest by getting {
        dependsOn(commonMain)

        dependencies {
            implementation(kotlin("test-common"))
            implementation(kotlin("test-annotations-common"))
            implementation("org.jetbrains.kotlin:kotlin-test-junit:1.4.10")
        }
    }

    val androidMain by getting {
        dependencies {
            implementation("androidx.core:core-ktx:1.3.1")
            implementation("com.squareup.sqldelight:android-driver:1.4.3")
        }
    }

    val androidTest by getting {
        dependsOn(androidMain)
    }

    val iosMain by getting {
        dependencies {
            implementation("com.squareup.sqldelight:native-driver:1.4.3")
        }
    }

    val iosTest by getting {
        dependsOn(iosMain)
    }

    val iosX64Main by getting {
        dependsOn(iosMain)
    }

    val iosX64Test by getting {
        dependsOn(iosTest)
    }
}

tasks {
    register("universalFramework", org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask::class) {
        val debugMode = "DEBUG"
        val mode = System.getenv("CONFIGURATION") ?: debugMode
        baseName = "vPayConnectLib"

        val iosArm64Framework = iosArm64("ios").binaries.getFramework(mode)
        val iosX64Framework = iosX64().binaries.getFramework(mode)

        from(
            iosArm64Framework,
            iosX64Framework
        )

        destinationDir = buildDir.resolve("xcode-universal-framework")
        group = "Universal framework"
        description = "Builds a universal (fat) $mode framework"

        dependsOn(iosArm64Framework.linkTask)
        dependsOn(iosX64Framework.linkTask)
    }
}

}
android {
compileSdkVersion(29)
defaultConfig {
minSdkVersion(24)
targetSdkVersion(29)
versionCode = 1
versionName = “1.0”
}
buildTypes {
getByName(“release”) {
isMinifyEnabled = false
}
}
dependencies {
implementation(fileTree(mapOf(“dir” to “libs”, “include” to listOf("*.jar"))))
}
}
val packForXcode by tasks.creating(Sync::class) {
group = “build”
val mode = System.getenv(“CONFIGURATION”) ?: “DEBUG”
val framework = kotlin.targets.getByName(“ios”).binaries.getFramework(mode)
inputs.property(“mode”, mode)
dependsOn(framework.linkTask)
val targetDir = File(buildDir, “xcode-frameworks”)
from({ framework.outputDirectory })
into(targetDir)
}
tasks.getByName(“build”).dependsOn(packForXcode)

Any update on this?
I also don’t understand why androidMain and androidTest are not shown under the android view