Hi, if there is a “fun A(){…. return “” }” in my a...
# kotlin-native
v
Hi, if there is a “fun A(){…. return “” }” in my androidNativeArm64 now, there is also a “fun A(){…. return “”}” in my androidNativeArm32 This two fun A is all the same How can i write once for two platform ( Because import java.XXX, can’t write in commomMain )???? Thanks
a
just create androidNative folder for sources and add tho symlinks - androidNativeArm64, androidNativeArm32. but this not work for windows
v
I try to reference to write, but got error for no parameter "targets" in kotlin region
message has been deleted
This is my reference code
a
you use kotlin-multiplatform gradle plugin?
v
Yes
a
i not see what wrong...
v
Copy code
Could not find any public constructor for interface org.jetbrains.kotlin.gradle.plugin.KotlinTarget which accepts parameters [java.lang.String].
a
what was wrong?
v
Copy code
plugins {
    id 'org.jetbrains.kotlin.multiplatform' version '1.3.50'
}
repositories {
    mavenCentral()
}
group '<http://tw.com|tw.com>'
version '0.0.1'

apply plugin: 'maven-publish'

kotlin {

    androidNativeArm64("androidNativeArm64") {
    }
    androidNativeArm32("androidNativeArm32") {
    }

    iosArm64("iOSArm64") {
    }
    iosX64("iOSX64") {
    }

    jvm()

    sourceSets {
        commonMain {
            dependencies {
                implementation kotlin('stdlib-common')
            }
        }

        androidNativeMain {
        }
        configure([androidNativeArm64Main, androidNativeArm32Main]) {
            dependsOn androidNativeMain
        }

        iOSMain {
        }
        configure([iOSArm64Main, iOSX64Main]) {
            dependsOn iOSMain
        }

        jvmMain {
            dependencies {
                implementation kotlin('stdlib-jdk8')
            }
        }
    }

    targets {

        configure([androidNativeArm64, androidNativeArm32]) {
            compilations.main.cinterops {
                interop_base64 {
                    headers project.file("src/c_interop/krypto/base64/base64.h")
                }

                interop_aes256 {
                    headers project.file("src/c_interop/krypto/aes256/aes256.h")
                }

                interop_sha512 {
                    headers project.file("src/c_interop/krypto/sha512/sha512.h")
                }

                interop_hmacsha256 {
                    headers project.files("src/c_interop/krypto/hmacsha256/hmac.h", "src/c_interop/krypto/hmacsha256/sha256.h")
                }
            }

            binaries {
                sharedLib {
                    baseName = "AndroidNative"
                }
            }
        }

        configure([iOSArm64, iOSX64]) {
            compilations.main.cinterops {
                interop_base64 {
                    headers project.file("src/c_interop/krypto/base64/base64.h")
                }

                interop_aes256 {
                    headers project.file("src/c_interop/krypto/aes256/aes256.h")
                }

                interop_sha512 {
                    headers project.file("src/c_interop/krypto/sha512/sha512.h")
                }

                interop_hmacsha256 {
                    headers project.files("src/c_interop/krypto/hmacsha256/hmac.h", "src/c_interop/krypto/hmacsha256/sha256.h")
                }
            }

            binaries {
                framework {
                    baseName = "iOS"
                }
            }
        }
    }
}
Error Message
Copy code
Task 'androidNativeMainBinaries' not found in root project 'CCryptoProject'.
Sync Gradle fix this error
Thank you, @alex009