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

Marc Planas

12/07/2023, 4:43 PM
Hi all! Thank you in advance for your time! I have been playing around KMP for a few weeks, trying to replicate a project, but i have been blocked for days trying to import an “.aar” into de multiplatform project, what i’m trying to do is make it accessible from android code so i can use that library. I placed the “.aar” file into the libs folder, then imported in the androidMain dependencies like :
Copy code
implementation(files("./libs/spotify-app-remote-release-0.7.2.aar"))
i also added the following code into the
settings.gradle.kts
Copy code
flatDir {
    dirs("libs")
}
if i run the command androidDependences i see this entry (which i suspect that means that its included)
/Users/XXXXX/AndroidStudioProjects/kmp/YYYY/composeApp/libs/spotify-app-remote-release-0.7.2.aar
The thing is that when it comes to the kotlin code, i cannot import the library neither use it. I don’t know what i’m doing wrong. If someone can throw some light would love them forever 😂
p

Pablichjenkov

12/07/2023, 7:23 PM
Are you placing it in the Android target ?
m

Marc Planas

12/07/2023, 7:24 PM
yeah, inside
Copy code
sourceSets {
androidMain.dependencies {
p

Pablichjenkov

12/07/2023, 7:26 PM
But where are you placing the.aar file
m

Marc Planas

12/07/2023, 7:28 PM
<projectFolder>/composeApp/libs
p

Pablichjenkov

12/07/2023, 7:30 PM
Humm I am not familiar with the new template generator, how is that composeApp module looks like? Does it have a directory named androidMain? Try putting your aar in androidMain/libs
m

Marc Planas

12/07/2023, 7:32 PM
image.png
then the reference would be like :
Copy code
implementation(files("./src/androidMain/libs/spotify-app-remote-release-0.7.2.aar"))
?
didnt work 🥲
p

Pablichjenkov

12/07/2023, 7:50 PM
Instead of using
libs
in composeApp try using it in the androidApp module and check if that module androidApp has the Android Application plugin applied
Copy code
id("com.android.application")
m

Marc Planas

12/08/2023, 11:45 AM
you mean that i should create a new module for this ? Because the AndroidMain folder doesn’t have any build.gradle.kts
p

Pablichjenkov

12/08/2023, 1:09 PM
Usually is named androidApp not androidMain. androidMain is the target name but androidApp is an Android only module.
m

Marc Planas

12/08/2023, 1:37 PM
i did it !!! It works !!! OMG, i love you, basically i start trying with other templates and found one that gives me the AndroidApp module, i tried a few things and worked !! Thank you soooo much ❤️ ❤️ ❤️
p

Pablichjenkov

12/08/2023, 1:45 PM
😺 no problem Sr 👍