skydoves / sandwich

🥪 Sandwich is an adaptable and lightweight sealed API library designed for handling API responses and exceptions in Kotlin for Retrofit, Ktor, and Kotlin Multiplatform.
https://skydoves.github.io/sandwich/
Apache License 2.0
1.55k stars 101 forks source link

Unresolved reference when adding dependency to a Kotlin module #4

Closed FredNM closed 4 years ago

FredNM commented 4 years ago

Hi @skydoves, and thanks for this nice library

When adding this dependency to the build.gradle file of an Android module, it works fine. But doing the same in the build.gradle of a pure Kotlin module, I'm not able to see the library (Unresolved reference). The IDE suggests "Add library 'Gradle: com.github.skydoves:sandwich:1.0.4@aar' to classpath"; and even doing that doesn't solve the problem. This is my build.gradle file:

apply plugin: 'kotlin'

dependencies {
    // some other dependencies
    implementation "com.github.skydoves:sandwich:1.0.4"
}

Could you explain how to handle this issue? Thanks

skydoves commented 4 years ago

Hi, @FredNM! This library will works when you use the below plugins together.

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

This library uses some Android-based classes internally like LiveData, Runnable, Handler, etc. Could you explain details about why this library should be used in a pure Kotlin project? Thanks!

FredNM commented 4 years ago

Ok I understand. Thanks for answering. Actually I have a multi-module app, and my remote module where I do the Retrofit requests is a pure Kotlin module. I will move it to an Android module. Thanks.