# Kotlin OpenCV4.7 Integration Error

**URL:** <https://forum.opencv.org/t/kotlin-opencv4-7-integration-error/12977>\
**Category:** Android/Java\
**Tags:** kotlin\
**Created:** [April 27, 2023, 1:31pm UTC](https://forum.opencv.org/t/kotlin-opencv4-7-integration-error/12977 "2023-04-27T13:31:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![NanoKnyte](https://avatars.discourse-cdn.com/v4/letter/n/7ab992/32.png) [@NanoKnyte](https://forum.opencv.org/u/NanoKnyte)\
**Post date:** [April 27, 2023, 1:31pm UTC](https://forum.opencv.org/t/kotlin-opencv4-7-integration-error/12977/1 "2023-04-27T13:31:14Z")

</div>

Hi there,  
I’m new to OpenCV and I’m trying to integrate it to my new Android Project. I was able to import the SDK as a module, but when I added it as a dependency to the _app_ module I got this error:

```auto
Execution failed for task ':opencv:compileDebugKotlin'.
> 'compileDebugJavaWithJavac' task (current target is 1.8) and 'compileDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.
  Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain

```

I tried to resolve it on my own with no success. Please somebody help me as I’m running to meet a deadline.

I’m using **Android Studio Flamingo** and building with **gradle-8.0**.

Thank you

---

<div class="post-metadata">

**Author:** ![zeellos](https://avatars.discourse-cdn.com/v4/letter/z/a183cd/32.png) [@zeellos](https://forum.opencv.org/u/zeellos)\
**Post date:** [May 27, 2024, 9:35pm UTC](https://forum.opencv.org/t/kotlin-opencv4-7-integration-error/12977/2 "2024-05-27T21:35:01Z")

</div>

I have the same issue, I tried all the stackoverflow similar questions but no luck, just bumping the questions to see if there’s a samaritan that knows how to fix this.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [May 28, 2024, 6:49am UTC](https://forum.opencv.org/t/kotlin-opencv4-7-integration-error/12977/3 "2024-05-28T06:49:13Z")

</div>

> [@NanoKnyte](#):
>
> `jvm target compatibility should be set to the same Java version.`

I think it’d be a good idea to find out which versions are involved, and how to control them to be the same.

---

<div class="post-metadata">

**Author:** ![Peter\_Featherstone](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/peter_featherstone/32/8413_2.png) [@Peter\_Featherstone](https://forum.opencv.org/u/Peter_Featherstone)\
**Post date:** [August 9, 2024, 12:17pm UTC](https://forum.opencv.org/t/kotlin-opencv4-7-integration-error/12977/4 "2024-08-09T12:17:08Z")

</div>

I have the same problem with OpenCV4.10. Anybody fixed this?

---

<div class="post-metadata">

**Author:** ![rajmb](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rajmb](https://forum.opencv.org/u/rajmb)\
**Post date:** [August 11, 2024, 10:56am UTC](https://forum.opencv.org/t/kotlin-opencv4-7-integration-error/12977/5 "2024-08-11T10:56:33Z")

</div>

> [@NanoKnyte](#):
>
> `jvm target compatibility should be set to the same Java version`

Please check [kotlin - How to set compileJava' task ( 11) and 'compileKotlin' task (1.8) jvm target compatibility to the same Java version in build.gradle.kts? - Stack Overflow](https://stackoverflow.com/a/76060790/15202794) & see if it helps.

---

<div class="post-metadata">

**Author:** ![Benjamin\_Wegener](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/benjamin_wegener/32/11543_2.png) [@Benjamin\_Wegener](https://forum.opencv.org/u/Benjamin_Wegener)\
**Post date:** [November 23, 2024, 4:24pm UTC](https://forum.opencv.org/t/kotlin-opencv4-7-integration-error/12977/6 "2024-11-23T16:24:30Z")

</div>

```auto
    kotlinOptions {
        jvmTarget=11
    }

```

was missing in opencv:build.gradle
