Error:Program type already present: android.arch.lifecycle.LiveData

前端 未结 10 978
迷失自我
迷失自我 2020-12-06 04:32

When I press the run button in Android Studio, my app compiles but shows this error (redacted):

Error:Program type a         


        
10条回答
  •  星月不相逢
    2020-12-06 05:01

    Like Edric mention, this happens because some library still use the old version of android.arch.lifecycle:extensions library, that is android.arch.lifecycle:extensions:1.0.0.

    One way to handle this is by forcing the app to use the same version of that library (and if we can, use the newest one).

    There are two ways to do that:

    1. Explicitly defined the library version that we want to use in our Gradle, under dependencies section.

      implementation 'android.arch.lifecycle:extensions:1.1.1

    or

    1. Force resolution of the library, also under dependencies section.

      android {
          configurations.all {
              resolutionStrategy.force 'android.arch.lifecycle:extensions:1.1.1'
          }
      }
      

提交回复
热议问题