Hi everyone! I have a question about the differenc...
# multiplatform
v
Hi everyone! I have a question about the difference between
debug
and
release
aar I build from my KMP code. At the moment, I use my KMP project to share data layer between Android and iOS projects, which consume it as an external library. From KMP side I build two library variants for Android:
Copy code
androidTarget {
        publishLibraryVariants("release", "debug")
    }
But on Android I have to specify which version to use:
Copy code
debugImplementation("com.xxx.yyy:shared-android-debug:0.1")
    releaseImplementation("com.xxx.yyy:shared-android:0.1")
I wonder if I benefit from building different variants or should I just build a`release` only. Can someone share real use cases when such separation can be useful?
e
I believe it's supposed to work with
Copy code
implementation("com.xxx.yyy:shared-android:0.1")
v
Unfortunately, it doesn’t in my case. It can because of a mistake in my setup of course. I have a multi-module KMP project with modules: •
allshared
- contains all modules •
analytycs
common-entities
• … I have a dependency from
allshared
in my android
app
module (I have a DI graph initialization in allshared) and I have dependencies from
analytics
, where it is required in my feature modules. As a result, if I don’t declare debugImplementation/releaseImplementation separately I receive error like this:
Copy code
Duplicate class com.xxx.yyy.analytics.Analytics found in modules analytics-debug-runtime (com.xxx.yyy:analytics-android-debug:0.1) and analytics-release-runtime (com.xxx.yyy:analytics-android:0.1)
I ran
./gradlew app:dependencies
and it looks like on KMP side my modules depend on -debug artefacts, but my android app uses release versions and they are in conflict.
l
Dropping the
-android
suffix altogether should resolve to the right one:
implementation("com.xxx.yyy:shared:0.1")
On top of that, you can publish only the release variant if there's no debug specific code you need to be present only in debug mode.
v
But if I drop it, the app will use a
jar
instead of
aar
, right?
l
No
It will do magic with Gradle metadata
Even if there's a JVM target, the android one (if any) takes precedence in an android project.
v
Indeed. I see that it works.
l
Great!