https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
r

Rohan Maity

06/01/2019, 7:56 AM
According to docs to for android
Copy code
plugins {
    id("com.android.library")
    id("org.jetbrains.kotlin.multiplatform").version("1.3.31")
}

android { /* ... */ }

kotlin {
    android { // Create the Android target
        // Provide additional configuration if necessary
    }
}
. But following this I get
Copy code
CONFIGURE FAILED in 0s
Plugin [id: 'com.android.library'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (plugin dependency must include a version number for this source)
I am unable to apply android closure
g

gildor

06/01/2019, 8:15 AM
If you set Android Gradle plugin without version it means that it must be in build classpath (for example applied by root project or in buildscript
r

Rohan Maity

06/01/2019, 8:22 AM
Copy code
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
    }
}

plugins {
    id 'kotlin-multiplatform' version '1.3.31'
    id("com.android.library")
}

repositories {
    mavenCentral()
}
group 'io.thelimitbreaker'
version '0.0.1'

apply plugin: 'maven-publish'

kotlin {

    jvm()
    js()
    // For ARM, should be changed to iosArm32 or iosArm64
    // For Linux, should be changed to e.g. linuxX64
    // For MacOS, should be changed to e.g. macosX64
    // For Windows, should be changed to e.g. mingwX64
    linuxX64("linux"){
       binaries{
           sharedLib{
               baseName = "kparser"
           }
       }
    }

    sourceSets {
        commonMain {
            dependencies {
                implementation kotlin('stdlib-common')
            }
        }
        commonTest {
            dependencies {
                implementation kotlin('test-common')
                implementation kotlin('test-annotations-common')
            }
        }
        jvmMain {
            dependencies {
                implementation kotlin('stdlib-jdk8')
            }
        }
        jvmTest {
            dependencies {
                implementation kotlin('test')
                implementation kotlin('test-junit')
            }
        }
        jsMain {
            dependencies {
                implementation kotlin('stdlib-js')
            }
        }
        jsTest {
            dependencies {
                implementation kotlin('test-js')
            }
        }
        linuxMain {
        }
        linuxTest {
        }
    }
}

wrapper {
    gradleVersion = "5.1.1"
    distributionType = "ALL"
}
This is build.gradle file. I included buildScript closure . Still same error
PS : this is only gradle file. Its root gradle file
i

ilya.gorbunov

06/01/2019, 9:13 AM
The classpath specified in the
buildscript
block doesn't affect the
plugins
block in the same gradle file, because AFAIK
plugins
block is parsed and interpreted first of all.
g

gildor

06/01/2019, 9:49 AM
And have buildscript and plugin block for the same plugin in the samee module doesn't make sense, if you want to use plugins block, just register Android plugin in settings.gradle using
r

Rohan Maity

06/01/2019, 9:50 AM
How Can I register android plugin in setting.gradle ?
g

gildor

06/01/2019, 9:52 AM
See this section in Gradle doca
It's for Kotlin DSL, but it's exactly the same for Groovy
r

Rohan Maity

06/01/2019, 9:54 AM
Same is written for kotlin-multiplatform plugin in settings.gradle
I get it thanks
g

gildor

06/01/2019, 9:55 AM
Yes, it works for any plugin which not published to Gradle Plugins portal
r

Rohan Maity

06/02/2019, 2:23 PM
@gildor I have added android config block but now I am getting this error
Copy code
ERROR: Cannot read packageName from /home/thelimitbreaker/KParser/kparser/src/main/AndroidManifest.xml
Affected Modules: KParser.kparser
I have created the
AndroidManifest.xml
manually in specified path
Copy code
<manifest package="io.thelimitbreaker.kparser">

</manifest>
still getting this error
g

gildor

06/02/2019, 2:44 PM
Yes, you have to create Android manifest and set package manually
Check that your manifest XML is on correct dir
r

Rohan Maity

06/02/2019, 3:33 PM
It was mentioned
src/main/AndroidManifest.xml
when I didn't create the file. So I created the file in that directory. Still got same error
g

gildor

06/02/2019, 4:44 PM
idk, it's standard config, check paths again or share some sample if it doesn't work
r

Rohan Maity

06/02/2019, 5:05 PM
I restarted my system . It worked 😅
4 Views