Execution failed for task ':app:checkDebugDuplicateClasses'. Ionic4 Android

前端 未结 4 1283
你的背包
你的背包 2021-01-07 22:07

I\'m currently working on an ionic4 application, but recently it stopped working while building the application on an android reall device after adding https://ionicframewor

相关标签:
4条回答
  • 2021-01-07 22:17

    In my case, I removed this implementation under dependencies section in app level build.gradle file -

    implementation 'com.google.android.gms:play-services-ads:19.2.0'

    Remove or comment it out!!

    0 讨论(0)
  • 2021-01-07 22:21

    For me, just installing the plugins "cordova-plugin-androidx" and "cordova-plugin-androidx-adapter" solved this problem:

    $ ionic cordova plugin add cordova-plugin-androidx
    $ ionic cordova plugin add cordova-plugin-androidx-adapter
    
    0 讨论(0)
  • 2021-01-07 22:23

    I had this issue when I migrated to Androidx using the Android Studio feature but at the first time the migration was not successful so each time I tried to compile I ran into this issue.

    To resolve this issue, I did the following:

    [1] Comment all androidx dependencies in the app bundle.gradle file
    [2] Try the Migrate to Androidx. You can see this link in Refactor -> Migrate to Androidx. If the migration was successful, then
    [3] Uncomment all androidx dependencies in the app bundle.gradle file
    

    You may clean and build your project again, hopefully this error should disappear.

    0 讨论(0)
  • 2021-01-07 22:31

    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 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 something like below (which is what worked for me) but edit and add your own rules (if these do not work for you):

    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'
        }
      }
    }
    
    0 讨论(0)
提交回复
热议问题