Search code examples
scaladependenciessbtakkaversion

Akka Version Issue


I am using Akka for my project.

Here, the Dependencies.scala

import play.sbt.PlayImport.caffeine
import sbt._

object Dependencies {

  val akkaActorVersion      = "2.6.19"


  val akkaCluster       = "com.typesafe.akka"      %% "akka-cluster"        % akkaActorVersion
  val akkaProtobuf      = "com.typesafe.akka"      %% "akka-protobuf"       % akkaActorVersion
  val akkaRemote        = "com.typesafe.akka"      %% "akka-remote"         % akkaActorVersion

  val clientAPIDependencies: Seq[ModuleID] = Seq(
     Dependencies.akkaCluster,
     Dependencies.akkaProtobuf,
     Dependencies.akkaActorType,
    caffeine
  )

}

Error:-

java.lang.IllegalStateException: You are using version 2.6.19 of Akka, but it appears you (perhaps indirectly) also depend on older versions of related artifacts. You can solve this by adding an explicit dependency on version 2.6.19 of the [akka-cluster, akka-protobuf, akka-remote] artifacts to your project. Here's a complete collection of detected artifacts: (2.5.25, [akka-cluster, akka-protobuf, akka-remote]), (2.6.19, [akka-actor, akka-actor-typed, akka-protobuf-v3, akka-serialization-jackson, akka-slf4j, akka-stream]). See also: https://doc.akka.io/docs/akka/current/common/binary-compatibility-rules.html#mixed-versioning-is-not-allowed
[error] 

NOTE - I even tried the solution of this also link, i.e., adding all mentioned akka dependencies in the error message but still getting the same error.


Solution

  • Try using sbt dependencyTree and then grepping through it for one of the conflicting libraries, such ask akka-cluster.

    As others have mentioned, somewhere you have a dependency on an older version of Akka. I agree with Ivan, that it is likely in your Play import, but the dependency tree could help you confirm that and potentially point you towards resolving it.