I'm trying to add CameraX to an Android project using an older version of Kotlin

250 Views Asked by At

I'm trying to add CameraX to my project so added this to the root build.gradle file:

buildscript {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
        mavenCentral()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
        mavenCentral()

    }
}

And then I added in /pes/build.gradle (note that I had to exclude those groups because they were causing duplicates):

def camerax_version = "1.3.0-alpha07"

    implementation("androidx.camera:camera-core:${camerax_version}") {
        exclude group: 'com.google.android.gms'
        exclude group: 'org.jetbrains.kotlin'
    }
    implementation ("androidx.camera:camera-camera2:${camerax_version}") {
        exclude group: 'com.google.android.gms'
        exclude group: 'org.jetbrains.kotlin'
    }
    implementation("androidx.camera:camera-lifecycle:${camerax_version}") {
        exclude group: 'com.google.android.gms'
        exclude group: 'org.jetbrains.kotlin'
    }
    implementation("androidx.camera:camera-video:${camerax_version}") {
        exclude group: 'com.google.android.gms'
        exclude group: 'org.jetbrains.kotlin'
    }
    implementation("androidx.camera:camera-view:${camerax_version}") {
        exclude group: 'com.google.android.gms'
        exclude group: 'org.jetbrains.kotlin'
    }
    implementation("androidx.camera:camera-mlkit-vision:${camerax_version}") {
        exclude group: 'com.google.android.gms'
        exclude group: 'org.jetbrains.kotlin'
    }
    implementation("androidx.camera:camera-extensions:${camerax_version}") {
        exclude group: 'com.google.android.gms'
        exclude group: 'org.jetbrains.kotlin'
    }

And I get this error:

e: C:/Users/AMI/.gradle/caches/transforms-3/64ad5900933e780ce887a006f25ca2fd/transformed/jetified-camera-extensions-1.3.0-alpha07-api.jar!/META-INF/camera-extensions_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.1.16.
e: C:/Users/AMI/.gradle/caches/transforms-3/7dee4547e37043c00f427a0185d4b10d/transformed/jetified-camera-view-1.3.0-alpha07-api.jar!/META-INF/camera-view_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.1.16.
e: C:/Users/AMI/.gradle/caches/transforms-3/8f6f30467f847b66b16817abdf472683/transformed/jetified-camera-video-1.3.0-alpha07-api.jar!/META-INF/camera-video_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.1.16.
e: C:/Users/AMI/.gradle/caches/transforms-3/99bb6fcc1c04207e3b031d7cda6d0f11/transformed/jetified-camera-core-1.3.0-alpha07-api.jar!/META-INF/camera-core_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.1.16.
e: C:/Users/AMI/.gradle/caches/transforms-3/df896c991bee1d4be7efa89fb4fe6913/transformed/jetified-camera-camera2-1.3.0-alpha07-api.jar!/META-INF/camera-camera2_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.1.16.

Below is the part of my buildscript specifying the kotlin version. So it seems my project should be using Kotlin 1.3.61. However the error is complaining that it expected version 1.1.16 so surely my version is high enough?:

buildscript {
    // Butterknife end of life will not work with JAVA_VERSION_11
    ext.butterknifeVersion = '10.2.3'
    // Can not upgrade to 1.4.21, annotations issues related to not using Java 11
    ext.kotlin_version = '1.3.61'

I can't seem to understand why it's not working, can anyone explain?

0

There are 0 best solutions below