Reputation: 334
I'm still novice with Android and I want to create an app that has a navigation drawer and gets location updates. After creating a project with navigation drawer, I have dependencies like this:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:+'
implementation 'com.android.support:support-v4:+'
implementation 'com.android.support:design:+'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'}
Then I go through this tutorial: https://developer.android.com/training/location/receive-location-updates and it needs these dependencies:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
}
But when I put them together they conflict and I cannot find a way to solve them.
I tried adding exclusions, migrating to androidx, but all this doesn't help. I either get conflict like this:
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.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Or some conflicting packages if I try to fix manifest:
Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:26.1.0)
Is there a way to solve this so that both UI and Location works?
Upvotes: 0
Views: 1131
Reputation: 363745
You have to change
implementation 'com.google.android.gms:play-services-location:16.0.0'
This version uses the support libraries and you can't use androidx and support libraries together.
Use an updated version of play-services-location
migrated to androidx.
implementation 'com.google.android.gms:play-services-location:17.0.0'
Upvotes: 1