Marco Ottina
Marco Ottina

Reputation: 589

Add specific artifact to a Gradle project (Androind)

I need to use, in an Android project using Gradle, a specific artifact of a repositorty. The artifact is kotlinx-serialization-cbor version 0.20.0 (available in the readme) from the kotlinx serialization GitHub project. I don't know where and how to add this specific dependencies. (Probably I should add something in "gradle.build" file, the one marked as Project:YourProjectName or the one Module:app Any help?

Upvotes: 0

Views: 296

Answers (2)

davkutalek
davkutalek

Reputation: 387

The README in the root of the github project explains how to add the plugins to your project. So long as your gradle install is up to date you just need to add a section at the top of your app level build.gradle like this:

plugins {
    id 'org.jetbrains.kotlin.multiplatform' version '1.3.70' // or any other kotlin plugin
    id 'org.jetbrains.kotlin.plugin.serialization' version '1.3.70'
}

In the same file make sure jcenter is included in your repositories:

repositories {
    jcenter()
}

Then again in the same file add the basic library, as well as the cbor library to the dependencies:

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" // or "kotlin-stdlib-jdk8"
    implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0" // JVM dependency
    implementation "org.jetbrains.kotlinx:kotlinx-serialization-cbor:0.20.0"
}

Upvotes: 1

ror
ror

Reputation: 3500

You should probably look here https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-serialization-cbor/0.20.0 and copy-paste from Gradle/Maven etc (build system of your choice).

Upvotes: 0

Related Questions