-
Couldn't load subscription status.
- Fork 132
Description
Feature request to support using the Android KMP plugin and update the sample projects within the repo to demonstrate configuring a project with it.
Google have introduced a KMP specific gradle plugin which should be used going forward instead of the regular Android library plugin:
The
com.android.kotlin.multiplatform.libraryplugin is the official replacement for the previous method of adding Android targets to KMP libraries using the regular Android library Gradle plugin (com.android.library).
The previous approach is now deprecated in favor of the plugin, also referred to as the Android-KMP plugin. Continuing to use the com.android.library plugin for KMP will no longer be supported by JetBrains and won't benefit from future updates and improvements.
Building a project including Moko Resources with the com.android.kotlin.multiplatform.library plugin applied results in build errors:
e: path/KMPExample/shared/build/generated/moko-resources/androidMain/src/com/example/kmpexample/shared/MR.kt:18:33 Too many arguments for 'constructor(): ResourcePlatformDetails'.
e: path/KMPExample/shared/build/generated/moko-resources/androidMain/src/com/example/kmpexample/shared/MR.kt:22:65 No parameter with name 'resourcesClassLoader' found.
e: path/KMPExample/shared/build/generated/moko-resources/androidMain/src/com/example/kmpexample/shared/MR.kt:23:27 Unresolved reference 'resourcesClassLoader'.
e: path/KMPExample/shared/build/generated/moko-resources/androidMain/src/com/example/kmpexample/shared/MR.kt:23:49 No parameter with name 'bundleName' found.
e: path/KMPExample/shared/build/generated/moko-resources/androidMain/src/com/example/kmpexample/shared/MR.kt:23:77 No parameter with name 'key' found.
e: path/KMPExample/shared/build/generated/moko-resources/androidMain/src/com/example/kmpexample/shared/MR.kt:23:77 No value passed for parameter 'resourceId'.
Building with androidResources.enable = true within the androidLibrary configuration results in a Gradle validation exception:
org.gradle.internal.execution.WorkValidationException: A problem was found with the configuration of task ':shared:generateMRandroidMain' (type 'GenerateMultiplatformResourcesTask').
- Gradle detected a problem with the following location: 'path/KMPExample/shared/build/generated/moko-resources/androidMain/res'.
Reason: Task ':shared:packageAndroidMainResources' uses this output of task ':shared:generateMRandroidMain' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
Possible solutions:
1. Declare task ':shared:generateMRandroidMain' as an input of ':shared:packageAndroidMainResources'.
2. Declare an explicit dependency on ':shared:generateMRandroidMain' from ':shared:packageAndroidMainResources' using Task#dependsOn.
3. Declare an explicit dependency on ':shared:generateMRandroidMain' from ':shared:packageAndroidMainResources' using Task#mustRunAfter.
Sample project:
KMPExample.zip