Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kotlin androidMain和android测试文件夹未识别为模块_Kotlin_Intellij Idea_Kotlin Multiplatform - Fatal编程技术网

Kotlin androidMain和android测试文件夹未识别为模块

Kotlin androidMain和android测试文件夹未识别为模块,kotlin,intellij-idea,kotlin-multiplatform,Kotlin,Intellij Idea,Kotlin Multiplatform,我一直在努力解决这个问题,因为天,但无法找到任何解决方案,所以我希望我可以得到任何帮助在这里。 我使用IntelliJ IDEA 2020.2.1中的移动应用程序模板创建了一个多平台项目,因为项目设置androidMain和AndroidTest文件夹未被识别为模块。在启动androidApp任务或PackForXcode时,这似乎不是问题,因为预期/实际定义的引用已解决,但idea建议显示androidMain引用似乎是错误的,因为根据屏幕截图,引用似乎已从父vpayConnectLib模块中

我一直在努力解决这个问题,因为天,但无法找到任何解决方案,所以我希望我可以得到任何帮助在这里。 我使用IntelliJ IDEA 2020.2.1中的移动应用程序模板创建了一个多平台项目,因为项目设置androidMain和AndroidTest文件夹未被识别为模块。在启动androidApp任务或PackForXcode时,这似乎不是问题,因为预期/实际定义的引用已解决,但idea建议显示androidMain引用似乎是错误的,因为根据屏幕截图,引用似乎已从父vpayConnectLib模块中解决。

我使用标准的android()目标

启动CompiledBugandroidTestKotlinAndroid任务时,会突出显示此错误

我试图用不同的模板创建新项目,但androidMain和androidTest文件夹从一开始就不被视为是所有项目模板的模块

这是一个已知错误还是我做错了什么?下面是我正在使用的根项目gradle文件及其版本

Hre的我的根项目gradle文件:

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()
}
这是共享库gradle文件

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<JacocoReport>("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<KotlinNativeTarget>("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)
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
插件{
科特林(“多平台”)
id(“com.android.library”)
id(“kotlin android扩展”)
id(“com.squareup.sqldelight”)
id(“org.qube”)
杰科科
}
group=“com.retailinmotion”
version=“1.0-SNAPSHOT”
存储库{
gradlePluginPortal()
谷歌()
jcenter()
mavenCentral()
}
sqldelight{
数据库(“vPayConnectDatabase”){
packageName=“com.retailinmotion.vpayconnect”
sourceFolders=listOf(“sqldelight”)
}
}
任务(“jacocoTestReport”){
dependsOn(“testDebugUnitTest”)
报告{
xml.isEnabled=true
csv.isEnabled=false
html.isEnabled=true
}
sourceDirectories.setFrom(文件(fileTree(“../vPayConnectLib”))
setFrom(文件(fileTree(“build/tmp/kotlin classes/debug”))
setFrom(文件(“build/jacoco/testDebugUnitTest.exec”))
}
声纳库贝{
性质{
属性(“sonar.sourceEncoding”、“UTF-8”)
属性(“sonar.java.coveragePlugin”、“jacoco”)
属性(“sonar.sources”、“src/commonMain/kotlin、src/iosMain/kotlin、src/androidMain/kotlin”)
属性(“sonar.tests”、“src/commonTest/kotlin、src/iosTest/kotlin、src/androidTest/kotlin”)
属性(“sonar.binaries”、“build/tmp/kotlin classes/debug”)
属性(“sonar.java.binaries”、“build/tmp/kotlin classes/debug”)
属性(“sonar.java.test.binaries”、“build/tmp/kotlin classes/debugUnitTest”)
属性(“sonar.junit.reportpath”、“构建/测试结果/testDebugUnitTest”)
属性(“sonar.jacoco.reportpath”、“build/jacoco/testDebugUnitTest.exec”)
属性(“sonar.coverage.jacoco.xmlReportPath”、“build/reports/jacoco/jacoctestreport/jacoctestreport.xml”)
}
}
科特林{
安卓()
iosArm64(“ios”){
二进制文件{
框架{
baseName=“vPayConnectLib”
}
}
汇编[“主要”]。cinterops{
//导入Datecs库
通过创建{
packageName(“com.retailinmotion.datecs”)
defFile=file($projectDir/src/iosMain/c_interop/Datecs.def)
includeDirs($projectDir/src/iosMain/c_interop/Datecs/)
}
//导入Datecs Utils库
val datecsutils通过创建{
packageName(“com.retailinmotion.datecsutils”)
defFile=file($projectDir/src/iosMain/c_interop/DatecsUtils.def)
includeDirs($projectDir/src/iosMain/c_interop/DatecsUtils/)
}
//导入Magtek库
val magtek通过创建{
packageName(“com.retailinmotion.magtek”)
defFile=file($projectDir/src/iosMain/c_interop/Magtek.def)
包括IRS($projectDir/src/iosMain/c_interop/Magtek)
}
}
}
iosX64(){
二进制文件{
框架{
baseName=“vPayConnectLib”
}
}
汇编[“主要”]。cinterops{
//导入Datecs库
通过创建{
packageName(“com.retailinmotion.datecs”)
defFile=file($projectDir/src/iosMain/c_interop/Datecs.def)
includeDirs($projectDir/src/iosMain/c_interop/Datecs/)
}
//导入Datecs Utils库
val datecsutils通过创建{
packageName(“com.retailinmotion.datecsutils”)
defFile=file($projectDir/src/iosMain/c_interop/DatecsUtils.def)
includeDirs($projectDir/src/iosMain/c_interop/DatecsUtils/)
}
//导入Magtek库
val magtek通过创建{
packageName(“com.retailinmotion.magtek”)
defFile=file($projectDir/src/iosMain/c_interop/Magtek.def)
包括IRS($projectDir/src/iosMain/c_interop/Magtek)
}
}
}
源集{
通过获取{
依赖关系{
实现(“com.squareup.sqldelight:runtime:1.4.3”)
}
}
通过获取{
dependsOn(commonMain)
依赖关系{
实现(kotlin(“测试通用”))
实现(kotlin(“测试注释通用”))
实现(“org.jetbrains.kotlin:kotlin-test-junit:1.4.10”)
}
}
val androidMain通过获取{
依赖关系{
实现(“androidx.core:core-ktx:1.3.1”)
实现(“com.squareup.sqldelight:android驱动程序:1.4.3”)
}
}
val Android通过获取{
依赖