Adding assets to the generated .aar from Kotlin Multiplatform

Hi everyone,

I am currently developing a multiplatform library project for Android and iOS using Kotlin 1.4.0 and I want to include the assets folder in the generated aar. I place the assets folder in the expected directory (same level as the AndroidManifest.xml) but in the final package (debug or release aar) there are only three items:

  • AndroidManifext.xml
  • R.txt
  • classes.jar

Is it possible to add the “assets” or “res” folder to the aar with the Kotlin Multiplatform at the moment?

Thanks

Of course it is! When you create an Android target the source sets for resources and res are created in src/main since you have to add the Android plugin as well! You can align the sources with the rest of the K/MPP ones with:

android {
    sourceSets.all {
        java.srcDirs(project.file("src/android${name.capitalize()}/kotlin"))
        res.srcDirs(project.file("src/android${name.capitalize()}/res"))
        resources.srcDirs(project.file("src/android${name.capitalize()}/resources"))
        manifest.srcFile(project.file("src/android${name.capitalize()}/AndroidManifest.xml"))
    }
}

This way everything will be in src/androidMain/... :slight_smile:

2 Likes

Thanks a lot @lamba92 !