Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes?

一笑奈何 提交于 2019-11-27 22:44:59
nice j

You can add below lines into your gradle.properties file:

android.useAndroidX=true
android.enableJetifier=true

I run into something like this, and below is based on my other answer:

Your project (or one of its sub-projects) is referring to a dependency using the + plus-sign at its end, like com.google.firebase:firebase-auth:+, which means, use any higher version when possible, and that newer version is no longer using android.support libraries and instead is using androidx; to fix this issue follow the below steps.

Steps:

  1. Ensure the ANDROID_HOME environment-variable is set, and then, open a console window (like git-bash, because it keeps the whole command output), and cd into your android directory (for Ionic projects it should be platforms/android).
  2. First, List all dependencies by running below (in git-bash):
    ./gradlew :app:dependencies
    
  3. Copy the result into your preferred text-editor, and search for androidx.
  4. If you found something follow below steps, else you are done! (and you do not need to repeat these steps).
  5. Scroll up until you see -> at the end of any line, like for example 16.0.8 -> 19.0.0 or + -> 19.0.0, which both mean that the version was auto-resolved (to something higher than specified by you because of +).
  6. So, set the version down manually:
    • When possible, in your project (or sub-project) find and replace the + sign with a specific version.
    • Or, force a specific version of the dependencies like mentioned below.
  7. At last, repeat above steps (but instead of step one just clear the console).

To Force specific version of the dependencies add to your root build.gradle file something like below (which is what worked for me) but of course edit below and add your own rules (because these might not work for your case):

allprojects {
  // ...
  configurations.all {
    resolutionStrategy {
      force 'com.google.firebase:firebase-common:17.0.0'
      force 'com.google.android.gms:play-services-basement:16.2.0'
      force 'com.google.firebase:firebase-iid:16.0.0'
      force 'com.google.firebase:firebase-auth:17.0.0'
    }
  }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!