0

In my build.gradle, I've tried to add implementation 'com.google.firebase:firebase-dynamic-links:16.0.0', but then I've gotten this error:

ERROR: In project 'app' a resolved Google Play services library dependency depends on 
another at an exact version (e.g. "[15.0.4]", but isn't being resolved to that version.
Behavior exhibited by the library will be unknown.

Dependency failing: com.google.firebase:firebase-analytics-impl:16.0.0 -> 
com.google.android.gms:play-services-measurement-base@[15.0.4],
but play-services-measurement-base version was 16.5.0.

The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
ifact with the issue.
-- Project 'app' depends onto com.google.android.gms:play-services-measurement@{strictly 16.5.0}
-- Project 'app' depends onto com.google.firebase:firebase-analytics@{strictly 16.5.0}
-- Project 'app' depends onto com.google.android.gms:play-services-measurement-base@{strictly 16.5.0}
-- Project 'app' depends onto com.google.firebase:firebase-dynamic-links@16.0.0
-- Project 'app' depends onto com.google.firebase:firebase-analytics-impl@{strictly 16.0.0}
-- Project 'app' depends onto com.google.android.gms:play-services-measurement-sdk-api@{strictly 16.5.0}
-- Project 'app' depends onto com.google.android.gms:play-services-measurement-api@{strictly 16.5.0}
-- Project 'app' depends onto com.google.android.gms:play-services-measurement-sdk@{strictly 16.5.0}
-- Project 'app' depends onto com.google.firebase:firebase-core@16.0.9
-- Project 'app' depends onto com.google.android.gms:play-services-measurement-impl@{strictly 16.5.0}
-- Project 'app' depends onto com.google.firebase:firebase-core@{strictly 16.0.9}
-- Project 'app' depends onto com.google.firebase:firebase-dynamic-links@{strictly 16.0.0}

For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b
uild.gradle file.

Here's how the build.gradle looks before adding dynamic link

dependencies {

    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'

    implementation 'com.google.firebase:firebase-core:16.0.9'
    implementation 'com.google.firebase:firebase-messaging:18.0.0'
    implementation 'com.google.firebase:firebase-auth:17.0.0'
    implementation 'com.google.firebase:firebase-storage:17.0.0'
    implementation 'com.google.firebase:firebase-firestore:19.0.1'
    implementation 'com.firebaseui:firebase-ui-firestore:4.2.1'

    implementation 'com.google.android.gms:play-services-base:16.1.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'com.google.android.gms:play-services-gcm:16.1.0'
    implementation 'com.google.android.gms:play-services-identity:16.0.0'
    implementation 'com.google.android.gms:play-services-auth-api-phone:16.0.0'

}
apply plugin: 'com.google.gms.google-services'

I've tried to update my Firebase dependencies as well, but whenever I do then I run into this error-

ERROR: Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
    is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
    Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:16:5-188:19 to override.

Hence, I've kept them in their older versions to avoid the above.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
Abhinav Prakash
  • 153
  • 2
  • 10
  • Have you tried updating your support libraries to androidx instead? When your manifests are merging, it is finding two dependencies that have the same appComponentFactory. Looks to me like you need to remove that support library and migrate to androidx. – brandonx Aug 13 '19 at 22:53
  • Possible duplicate of [Manifest merger failed : Attribute application@appComponentFactory - Androidx](https://stackoverflow.com/questions/55217992/manifest-merger-failed-attribute-applicationappcomponentfactory-androidx) – brandonx Aug 13 '19 at 22:57
  • @brandonx these versions don't have `androidx` - he wrote this only happens when trying to update them; also thought so at first, but that only changed later on: https://firebase.google.com/support/release-notes/android#firebase_bill_of_materials_firebase_bom_version_2001 the actual problem is `Dependency failing: com.google.firebase:firebase-analytics-impl:16.0.0 -> com.google.android.gms:play-services-measurement-base@[15.0.4], but play-services-measurement-base version was 16.5.0.` – Martin Zeitler Aug 13 '19 at 22:57
  • @MartinZeitler I definitely understand the issue. My opinion is he should stop resisting the update and migrate to androidx and update his firebase versions. Better use of his time to migrate than to diagnose dependency conflicts. – brandonx Aug 13 '19 at 23:00
  • firebase analytics wants an older version of play-services-measurement-base. – brandonx Aug 13 '19 at 23:03

1 Answers1

0

One cannot depend on com.android.support and androidx at the same time - and later versions of either Google Play Services and Firebase all pull in androidx dependencies. These options are available to chose from:

  • either downgrade the dependencies to versions which still used com.android.support.
  • or migrate to androidx:

dependencies {

    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'

    implementation 'com.google.firebase:firebase-core:17.0.1'
    implementation 'com.google.firebase:firebase-messaging:19.0.1'
    implementation 'com.google.firebase:firebase-auth:18.1.0'
    implementation 'com.google.firebase:firebase-storage:18.1.1'
    implementation 'com.google.firebase:firebase-firestore:20.2.0'
    implementation 'com.firebaseui:firebase-ui-firestore:4.2.1'

    implementation 'com.google.android.gms:play-services-base:17.1.0'
    implementation 'com.google.android.gms:play-services-location:17.0.0'
    implementation 'com.google.android.gms:play-services-auth:17.0.0'
    implementation 'com.google.android.gms:play-services-gcm:17.0.0'
    implementation 'com.google.android.gms:play-services-identity:17.0.0'
    implementation 'com.google.android.gms:play-services-auth-api-phone:17.1.0'
}
Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • I don't really understand why it would be necessary to migrate the whole thing to androidx if implementing dynamic links is the only issue arising. However, I'll try to downgrade the dependency. Would you know which version of firebase dynamic links to use? I have used 16.0.0 in a previous project without any issue, but that version is clearly not working here. – Abhinav Prakash Aug 14 '19 at 13:44