dji-sdk / Mobile-UXSDK-Android

DJI Mobile UXSDK is a suite of product agnostic UI objects that fast tracks the development of Android applications using the DJI Mobile SDK.
Other
152 stars 110 forks source link

Please update the version of com.google.android.gms:play-services-location in the UX library #36

Open JamesMasterman opened 6 years ago

JamesMasterman commented 6 years ago

The 4.5 version of the UX library includes mapping functions. There is a dependency on com.google.android.gms:play-services-location inside the library.

In the latest version of Android studio (3.1.1), the compiler is much stricter and when building the dex archives for my app, I get an error "Program type already present: com.google.android.gms.location.places.zzl"

This is a new an extremely frustrating error that Android Studio 3.1.1 seems to cause quite a bit. The cause is two libraries being imported that both reference a 3rd library (in this case the play-services-location library). The only solution I've found is to remove one of the libraries.

However, in this case, I can't do that as the version of play-services-location and play-services-places used by the UX library are ancient (v9.4.0), while the rest of my app is using the latest google libraries, v12.0.1.

Would it be possible to update the UX library to use 12.0.1?

JamesMasterman commented 6 years ago

FYI - for anyone who comes across this issue, importing the ux library like this

implementation ('com.dji:dji-uxsdk:4.5'){
        transitive = false
}

worked for me.

Just be careful that if your app relies on any libraries that the uxsdk was itself importing, you will now need to import them explicitly yourself.

Also be aware that the package name of all the components has changed and the tutorial has not yet been updated. You need to replace dji.ui. with dji.ux. in your layout files, and the names of some components has changed.

codeversed commented 6 years ago

You can also make sure every dependency is using the same version of specific libraries. Here is what I add to my app level build.gradle:

// This resolves multidex merging with multiple specific library versions
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion "${supportLibVersion}"
            }
        } else if (requested.group == 'com.google.android.gms') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion "${playServicesVersion}"
            }
        }
    }
}
JamesMasterman commented 6 years ago

Thanks for that tip, I had tried playing with resolution strategies, but couldn't get it to work. Looks like the "multidex" check fixed it for me.

Edit: I have since updated my com.google.android.gms libraries to v15.0.0 and the issue seems to have gone away without needing the transitive=false statement.