Hi all! Thank you in advance for your time! I have...
# multiplatform
m
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
Are you placing it in the Android target ?
m
yeah, inside
Copy code
sourceSets {
androidMain.dependencies {
p
But where are you placing the.aar file
m
<projectFolder>/composeApp/libs
p
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
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
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
you mean that i should create a new module for this ? Because the AndroidMain folder doesn’t have any build.gradle.kts
p
Usually is named androidApp not androidMain. androidMain is the target name but androidApp is an Android only module.
m
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
😺 no problem Sr 👍