[Android] Why a conflict version error occurs when loading some library on the Android app side

Introduction

When developing on Android and loading and executing some library with gradle as a common problem, kotlin version conflict type error may occur. So opinion

I did a little research, so I'll leave it as a memo

Cause

There may be various reasons, but first it can happen if you are in conflict with the kotlin version of the library. In that case, do not know whether to give up using the library in the first place, try using an older version of the library, or upgrade the kotlin version of the application that incorporates the library, and solve it by trial and error. I often do it.

kotlin library conflict

When you load the kotlin library, the kotlin library will be loaded on the application side. The size of the apk and the number of methods will increase accordingly. Maybe you need multi dex.

It seems that there may be a conflict between the kotlin library loaded on the app side and the kotlin version on the app side. Please refer to the following for the use of gradle. If there is a conflict with the kotlin version, it will be overwritten with the new version. Since it is the default behavior, it should be solved even if you make a setting that does not overwrite here with the latest in the gradle file. (unconfirmed)

Behavior in the event of a conflict https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html#org.gradle.api.artifacts.ResolutionStrategy:failOnVersionConflict()

Solutions

Make it the same version as the latest implemented library on the application side. Or more may solve the problem. If the library and app development are the same, it can be implemented without problems, but in most cases the library should be implemented by another company or another individual. Therefore, it may be necessary for library makers to always upgrade with the latest kotlin and encourage documents to use the latest kotlin.

Or if you implement the library in java instead of kotlin, this problem should not occur because the kotlin library will not be loaded on the application side. must.

Recommended Posts

[Android] Why a conflict version error occurs when loading some library on the Android app side
I made a calculator app on Android
A reminder when an aapt.exe error occurs
My thoughts on the future [Gradle app version ①]
Rails <% = expression%> Why no error occurs when empty
Get your version number in the Android app
I have a question. I get an error when playing a video in Listview on android.