Problem duplicate class androidx.lifecycle.viewmodel found in modules

Most likely, one of your dependencies uses the kotlin version of the viewmodel library whereas your code uses the java version.

Specify both to enforce the latest version for all dependencies:

def lifecycle_version = "2.4.0"
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"

Leave a Comment