Skip to content

Commit 58618c9

Browse files
authored
[camerax] Add a dependency on kotlin-bom to align versions of kotlin-stdlib (#3960)
A fresh sample app that adds a dependency on the camerax implementation of the camera plugin will fail to build with an error about duplicate classes*. This PR adds a dependency on kotlin-bom to align versions of kotlin transitive dependencies that are used. The idea for the fix comes [from here](https://youtrack.jetbrains.com/issue/KT-55297/kotlin-stdlib-should-declare-constraints-on-kotlin-stdlib-jdk8-and-kotlin-stdlib-jdk7), which has some more discussion about the problem (but in a different context, unrelated to flutter). \* The error looks like this: ``` FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:checkDebugDuplicateClasses'. > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable > Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30) Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk7-1.7.10 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10) ... ```
1 parent f452344 commit 58618c9

5 files changed

Lines changed: 11 additions & 11 deletions

File tree

packages/camera/camera_android_camerax/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.5.0+2
2+
3+
* Adds a dependency on kotlin-bom to align versions of Kotlin transitive dependencies.
4+
* Removes note in `README.md` regarding duplicate Kotlin classes issue.
5+
16
## 0.5.0+1
27

38
* Update `README.md` to include known duplicate Kotlin classes issue.

packages/camera/camera_android_camerax/README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,6 @@ Any specified `ResolutionPreset` wll go unused in favor of CameraX defaults and
4949

5050
`setZoomLevel` is unimplemented.
5151

52-
## Known Issues
53-
54-
### Receiving `Duplicate class kotlin.*` error
55-
56-
If you receive a `Duplicate class kotlin.*` error when using this plugin
57-
implementation, you may need to update your app's Kotlin version. You can do
58-
this by finding your app's `android/build.gradle` file and updating the
59-
`org.jetbrains.kotlin:kotlin-stdlib-jdk7` dependency to at least version 1.18.10.
60-
6152
## Contributing
6253

6354
For more information on contributing to this plugin, see [`CONTRIBUTING.md`](CONTRIBUTING.md).

packages/camera/camera_android_camerax/android/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,8 @@ dependencies {
7272
testImplementation 'org.mockito:mockito-inline:5.0.0'
7373
testImplementation 'androidx.test:core:1.4.0'
7474
testImplementation 'org.robolectric:robolectric:4.8'
75+
76+
// org.jetbrains.kotlin:kotlin-bom artifact purpose is to align kotlin stdlib and related code versions.
77+
// See: https://youtrack.jetbrains.com/issue/KT-55297/kotlin-stdlib-should-declare-constraints-on-kotlin-stdlib-jdk8-and-kotlin-stdlib-jdk7
78+
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.10"))
7579
}

packages/camera/camera_android_camerax/example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlin_version = '1.8.0'
2+
ext.kotlin_version = '1.7.10'
33
repositories {
44
google()
55
mavenCentral()

packages/camera/camera_android_camerax/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Android implementation of the camera plugin using the CameraX libra
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android_camerax
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
55

6-
version: 0.5.0+1
6+
version: 0.5.0+2
77

88
environment:
99
sdk: ">=2.19.0 <4.0.0"

0 commit comments

Comments
 (0)