yayaa / LocationManager

Simplify getting user's location for Android
807 stars 187 forks source link

No class def found with newer version of play services #13

Closed branoh closed 7 years ago

branoh commented 7 years ago

Problem Description

If I use the library with a newer version of play services(9.6.1), the app crashes becauase of a NoClassDefFoundError (with play-services-location exclude option specified for the LocationManager dependency).

java.lang.NoClassDefFoundError: com.yayandroid.locationmanager.provider.GPServicesLocationProvider at com.yayandroid.locationmanager.LocationManager.locationPermissionGranted(LocationManager.java:278) at com.yayandroid.locationmanager.LocationManager.askForPermission(LocationManager.java:262) at com.yayandroid.locationmanager.LocationManager.get(LocationManager.java:210) at com.yayandroid.locationmanager.LocationManager.get(LocationManager.java:182) at com.yayandroid.locationmanager.LocationBaseActivity.getLocation(LocationBaseActivity.java:28)

Proposed Solution

Update Google Play services dependecy to a newer version.

I've tried to compile the library with play-servives 9.6.1 dependency and then the NoClassDefFoundError does not occur.

branoh commented 7 years ago

Pull request here: #14

yayaa commented 7 years ago

In a matter of fact, you could replace GooglePlayServices by excluding the old version that library uses like this:

compile('com.google.android.gms:play-services-location:9.6.1') {
        exclude group: 'com.google.android.gms', module: 'play-services-location'
    }

But still, i don't see any drawback to update GooglePlayServices in the library itself, but i need to check if that causes any other problems or not. Give me some time to investigate the PR and if everything is fine, i'll merge it :) Thanks a lot!

branoh commented 7 years ago

Thanks for your reply. I've realised where I made a mistake. It was assuming that play-services-maps have the play-services-location dependency. That's why it crashed with the NoClassDefFoundError when I used the exclude statement in the LibraryManager dependecy.

pollaken commented 7 years ago

@yayaa It would be great if you could update it to make it work with Firebase that uses

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:3.0.0'

    }
}

and

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

branoh commented 7 years ago

@pollaken What exactly doesn't work if you use Firebase? I'm using Firebase in one of my apps together with LocationManager and it works well.

yayaa commented 7 years ago

Merged @branoh , thanks for PR :) I'll upload to gradle soon

@pollaken sorry, including Firebase is not something necessary (and also will include more stuff than needed) for this library. To do that you can try to extract GooglePlayServices as i described above and put Firebase instead, or you can fork and customize library for your requirements.