I'm currently working on a Kotlin Multiplatform project (Kotlin 1.3.50, Gradle 3.6.0-beta04) and want to use the Kissme Storage library.
It works on Android as expected, but trying to compile on a Mac for the iOS target, I get
Unresolved reference: netguru
and
Unresolved reference: Kissme
It's mentioned on GitHub, that publishing to maven local could help. But after fetching the git repository, I can't build the library, because there is missing a secret.gradle file.
How can I bring it to work? Is anybody else using this library?
In app's build.gradle:
sourceSets {
commonMain {
dependencies {
implementation 'com.netguru.kissme:common:0.2.5'
}
}
androidMain {
dependencies {
implementation 'com.netguru.kissme:android:0.2.5'
}
}
iosMain {
dependencies {
implementation 'com.netguru.kissme:ios:0.2.5'
}
}
Related
I am trying to get a SNAPSHOT of a plugin that may fix our issue, but the I cannot get the library:
plugins {
kotlin("jvm") version "1.7.10"
id("maven-publish")
id("org.jetbrains.kotlin.plugin.serialization") version "1.7.10"
id("org.openapi.generator") version "6.1.0-SNAPSHOT"
}
I have already added all the necessary repositories, but still get this error:
Plugin [id: 'org.openapi.generator', version: '6.1.0-SNAPSHOT'] was not found in any of the following sources
(If I use the released 6.0.1 version, everything works fine)
Attempt 2: I have tried to get the plugin in another way.
buildscript {
repositories {
maven("https://companyserver.io/company-maven-snapshot")
// or, via Gradle Plugin Portal:
// url
}
dependencies {
classpath ("org.openapitools:openapi-generator-gradle-plugin:6.0.1")
}
}
apply(plugin="org.openapi.generator")
This seems to find the plugin, but I still get an error on the first line of:
openApiGenerate {
generatorName.set("kotlin")
inputSpec.set("$projectDir/mapi-open-api-spec.json")
modelPackage.set("mapi.generated.models")
apiPackage.set("mapi.generated.apis")
invokerPackage.set("mapi.generated.invokers")
configOptions.put("library", "multiplatform")
typeMappings.put("kotlin.Any", "kotlin.String") // change autogenerated data type of generated templates
kotlin.sourceSets["main"].kotlin.srcDir("$buildDir/generate-resources/main/src/main/kotlin")
}
The error:
.../build.gradle.kts:75:1: Unresolved reference: openApiGenerate
I am a bit stuck now, any ideas?
I'm making a private Kotlin Multiplatform library that will be in a private repo hosted on Bitbucket.
My library depends on another library, called Krypto.
So, naturally, I have the following dependency in the common module of the library:
val commonMain by getting {
dependencies {
api("com.soywiz.korlibs.krypto:krypto:2.2.0")
}
}
Now, when I import the library via Cocoapods to an iOS project, it works perfectly fine. However when I insert the .jar file to my Android project as a dependency:
implementation files('libs/MyLibrary-jvm-1.0.0.jar')
it compiles, but at runtime crashes with the following error:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/soywiz/krypto/SHA256Kt
If I add the Krypto dependency to my Android project, everything works fine, however I would like the dependencies to be already included in my library. How to do that?
I also tried adding the java-library plugin and adding the dependency in a java build block, but it didn't change anything.
The solution was in the documentation all along... https://kotlinlang.org/docs/multiplatform-build-native-binaries.html#export-dependencies-to-binaries
In the Gradle configuration of the binaries of a specific platform we need to use export() to include dependencies. To also include dependencies of the dependencies, we need to do export(dep, transitiveExport = true).
kotlin {
sourceSets {
commonMain by getting {
dependencies {
api(project(":dependency"))
}
}
}
java().binaries {
framework {
export(project(":dependency"), transitiveExport = true)
}
}
}
I'm trying to build a java library for my other java projects. I'm also trying to learn gradle. There is a tutorial : https://docs.gradle.org/current/samples/sample_building_java_libraries.html shows how to build libraries with gradle.
But somehow when I use gradlew build it always gives me lib-< version >.jar and creates a folder called lib and I can't change it.
This is my settings.gradle
rootProject.name = 'myOwnLibrary'
include('lib')
this is my build.gradle (inside lib folder)
plugins {
// Apply the java-library plugin for API and implementation separation.
id 'java-library'
}
version = "0.1.1"
tasks.named('jar') {
manifest {
attributes('Implementation-Title': project.name,
'Implementation-Version': project.version)
}
}
repositories {
// Use JCenter for resolving dependencies.
jcenter()
}
dependencies {
// Use JUnit test framework.
testImplementation 'junit:junit:4.13'
// This dependency is exported to consumers, that is to say, found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:29.0-jre'
}
With Kotlin DSL example, you can add in your tasks jar the following snippet:
tasks.jar {
manifest {
attributes(mapOf("Implementation-Title" to rootProject.name,
"Implementation-Version" to project.version))
}
archiveBaseName.set(rootProject.name)
}
where rootProject.name, is the value localized into settings.gradle.kts file.
I have an Android library module that depends on a Kotlin Multiplatform module via project dependency. My issue is that when I try to go to the source of a class, it takes me to the imported sources jar instead of the project that I am depending on. Is it possible to have it take me to the project's source instead of to the sources artifact? My setup:
android-local/build.gradle.kts
dependencies {
api(project(":android-remote", "jvmDefault"))
}
I don't know if this is possible with the multiplatform plugin, but thought I would ask just in case.
In order to get this working correctly first I had to add Kotlin's multiplatform plugin to my Android library module. Then I used the jvmDefault configuration in my dependencies instead of hooking up a specific Android target in my MP project. Here is the build file for my android-local now:
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.multiplatform")
}
android {
//setup
}
kotlin {
android()
sourceSets {
val androidMain by getting {
dependencies {
api(project(":android-remote", "jvmDefault"))
}
}
}
}
And now I can go to sources in the android-remote project (which is a MPP). A bit unintuitive, but it works.
I can't make project in Android Studio.
When compile project I have some errors:
Gradle: error: package org.simpleframework.xml does not exist
Gradle: error: cannot find symbol class Element
Gradle: error: cannot find symbol class Element
I add jar manually and from Dependencies to project.
How to fix it ?!
OK, I fix It.
The problem was solved. I add manually to config file library libs/simple-xml-2.7.jar.
dependencies {
compile files('libs/android-support-v4.jar', 'libs/commons-net-3.3.jar', 'libs/simple-xml-2.7.jar')
}
You could also use Maven to declare that dependency in your build.gradle, like this:
dependencies {
[...]
compile 'org.simpleframework:simple-xml:2.7'
}
also make sure that you have maven central declared as a repository:
repositories {
[...]
mavenCentral()
}
Another common solution if you want to download the .jars by yourself is to include any .jar inside libs/, like that:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
[...]
}
Anyway, make sure that you don't include a library more than once, that could cause problems.