My project contains three modules: main - pure Java, 3rd-party app - pure Java and another 3rd-party app - Kotlin, 1.5.10
Project isn't maintained, but still works and I've got a task to implement some lib in it, in main module. I've developed whole solution without a problem on debug, but now when I'm trying to build release APK I'm getting 4 errors in :lintVitalBasicRelease stage similar to below
..f4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar!/META-INF/kotlin-stdlib.kotlin_module:
Module was compiled with an incompatible version of Kotlin.
The binary version of its metadata is 1.6.0, expected version is 1.4.0.
same for kotlin-stdlib-common-1.6.0.jar, preference-1.2.0.jar and slidingpanelayout-1.2.0.jar, same versions 1.6/1.4 mentioned in all
project gradle:
buildscript {
ext.kotlin_version = '1.5.10'
repositories {
jcenter()
flatDir {
dirs 'libs'
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
...
gradle for 3rd-party Kotlin app/module:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
...
dependencies {
compile "androidx.core:core-ktx:1.6.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
...
main module (no Kotlin!):
apply plugin: 'com.android.application'
android {
compileSdkVersion 31
buildToolsVersion '30.0.3'
defaultConfig {
minSdkVersion 21
targetSdkVersion 27
...
dependencies {
...
implementation('com.dji:dji-sdk:4.16.4', {
exclude module: 'fly-safe-database'
})
compileOnly 'com.dji:dji-sdk-provided:4.16.4'
...
implementation project(path: ':somekotlininhere')
implementation project(path: ':purejavamodule')
}
without posted above implementation of THIS SDK project is building and signing fine, I'm producing APK without a problem
fun fact that in linked sdk repo we can find Sample Code, which have exactly same Kotlin version (1.5.10) and dependecies, even declared same way (using shared ext.kotlin_version)
updating Kotlin to newest one 1.8.10 introduced some new errors/deprecations, after resolving I've got back to same point and initial error... I've reverted this change back, I'm not an author of Kotlin-module, I would prefer to not touch
so: what is proper declarations for my case, how can I release my project now, as it works pretty good "via cable" (debug)
PS. yep, this question is a duplicate of THIS, but I believe I've posted more useful and detailed info for resolving this...
Maybe putting the following lines of code in the project's Gradle works for you
Or maybe you need just turn off your lint warning
But I didn't recommend those.
The most difficult way is upgrading your dependencies, but it's more reliable.
In you're app Gradle use the following code depending on your Java version
Edited answer __________________________________
Also try following packaging option in your
app Gradle:And this progaurd rule in your
app progaurd file:Hope this pushing you forward :)