AdevintaSpain / Leku

:earth_africa: Map location picker component for Android. Based on Google Maps. An alternative to Google Place Picker.
https://adevintaspain.github.io/Leku/
Apache License 2.0
763 stars 170 forks source link

Tow many problems adding the library #152

Closed saefbadwan closed 6 years ago

saefbadwan commented 6 years ago
android {
    compileSdkVersion 27
    buildToolsVersion '27.0.2'
    defaultConfig {
        applicationId "xxxx"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 3
        versionName "1.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled  true // important

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        disable 'MissingTranslation'
    }

    dexOptions {
        //you can specify the heap size for the dex process
        javaMaxHeapSize "4g"
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

android.enableD8=true ,, when setting this to false you will get 4 error and you cant build

and when i bilut it buld fine ,, but it crash with this error

 E/AndroidRuntime: FATAL EXCEPTION: main
                                                                              Process: com.react.imyth.xxx, PID: 28904
                                                                              java.lang.NoSuchMethodError: No static method getGeoDataClient(Landroid/app/Activity;Lcom/google/android/gms/location/places/PlacesOptions;)Lcom/google/android/gms/location/places/GeoDataClient; in class Lcom/google/android/gms/location/places/Places; or its super classes (declaration of 'com.google.android.gms.location.places.Places' appears in /data/app/com.react.imyth.xxxx-1/base.apk)
                                                                                  at com.schibstedspain.leku.LocationPickerActivity.setUpMainVariables(LocationPickerActivity.java:167)
                                                                                  at com.schibstedspain.leku.LocationPickerActivity.onCreate(LocationPickerActivity.java:144)
                                                                                  at android.app.Activity.performCreate(Activity.java:6021)
                                                                                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
                                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2405)
                                                                                  at android.app.ActivityThread.access$800(ActivityThread.java:155)
                                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1323)
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                  at android.os.Looper.loop(Looper.java:135)
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:5376)
                                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                                  at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
    implementation 'com.google.android.gms:play-services-maps:11.0.2'
    implementation 'com.google.android.gms:play-services-location:11.0.2'
    implementation 'com.google.android.gms:play-services-ads:11.0.2'
    implementation 'com.google.android.gms:play-services-places:11.0.2'
   implementation ('com.schibstedspain.android:leku:4.0.0') {
        exclude group: 'com.google.android.gms'
        exclude group: 'com.android.support'
    }

I had to update my android studio so i can just put this lib ,, and i reached this error after a lot of errors before

saefbadwan commented 6 years ago

WILl I HAD TO REMOVE ALL THE LIBS INSIDE THE LIBRARY AND PUT THIEM INSIDE MY PROJECT like that

  implementation 'com.google.android.gms:play-services-maps:11.8.0'
    implementation 'com.google.android.gms:play-services-location:11.8.0'
    implementation 'com.google.android.gms:play-services-ads:11.8.0'
    implementation 'com.google.android.gms:play-services-places:11.8.0'
    implementation 'pl.charmas.android:android-reactive-location2:2.1@aar'
    implementation "io.reactivex:rxandroid:1.2.1"
    implementation 'io.reactivex.rxjava2:rxjava:2.1.7'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'nl.littlerobots.rxlint:rxlint:1.6'

    implementation ('com.schibstedspain.android:leku:4.0.0') {
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
        exclude group: 'com.google.android.gms', module: 'play-services-location'
        exclude group: 'com.google.android.gms', module: 'play-services-ads'
        exclude group: 'com.google.android.gms', module: 'play-services-places'
        exclude group: 'pl.charmas.android', module: 'android-reactive-location2:2.1@aar'
        exclude group: 'io.reactivex'
        exclude group: 'io.reactivex.rxjava2'
        exclude group: 'nl.littlerobots.rxlint'
    }

Will this get me more than half a day to figure this out

ferranpons commented 6 years ago

@saefbadwan you don't need to do this because google play services, reactive location and rxjava are bundled with the library. Using the latest version of play services should be enough.

Are you experiencing this issue on debug or release version? Are you using an emulator or a real device? If using the emulator, which API version of the emulator are you using?

saefbadwan commented 6 years ago

I tried what you said but when i let the lib use the bundled libraries i get 4 errors DexDebug or something like that ,, so i moved the lib bundled to the root project

On debug Real device

And about the search for the location ,, is just set to search in america , cuz im trying to search in my country and some other counters ,, and tried to search with different languages with no result , and can i remove the lat and lng , and only show country name or place name ?

ferranpons commented 6 years ago

@saefbadwan So if I'm not wrong the library is working now, right?

About what you ask, If your country is not listed in the [CountrylocaleRect.java](https://github.com/SchibstedSpain/Leku/blob/8d1e2ef10412eebdc74619f1db5d960b147e79cd/leku/src/main/java/com/schibstedspain/leku/CountryLocaleRect.java) file it will not search with the boundaries of your country. I mean it will return locations from other countries.

And about the Lat/Lng displayed is because the Geocoder does not retrieve the Address of the location selected. You have 2 options here, use the Google Maps Places implementation (documented on the Readme) or use the Google Maps Geocoding API that is a paid service.

JesperLR commented 6 years ago

Having a similar issue, getting e.g.: "Error:java.lang.ClassNotFoundException: Class io.reactivex.ObservableOnSubscribe not found" When trying to add the lib through Gradle - so it seems the lib does not have the right dependency description to allow the implementing project to implement it without having to make that list of depencies in your own gradle build file. Maybe include this list in the Readme until fixed for newcomers :)

ferranpons commented 6 years ago

@JesperLR that sounds weird because dependency definition for the library is exactly the same for a while. The only thing that could give some issues with the Dex could be the Build Tools version, Proguard (with release versions), using an old ide version, or you are using a gradle version that does not support "implementation" definitions. 🤔

JesperLR commented 6 years ago

@ferranpons Unfortunately I don't know much about what can result in this issue, but I can tell you that I am running AS 3.0.1 (the newest stable) and buildToolsVersion "26.0.2". It can't be related to Proguard as the issue is seen on compile time when trying to build the project. And the gradle and build tools version is new enough to support "implementation" - I have fixed it same way as @saefbadwan in his previous comment (which uses the implementation keyword), but of course it would be nicer if the dependencies of the lib did not have to be explicitly declared in the implementing gradle build file :)

CristianGM commented 6 years ago

@ferranpons maybe we should check the pom.xml file to check if the transitive dependencies are declared there.

ferranpons commented 6 years ago

@CristianGM you are right. The pom hasn't got the dependencies, I did not think about this possibility. 😓

It's not creating the pom.xml correctly since version 3.5.0 😱

ferranpons commented 6 years ago

@saefbadwan @JesperLR It's now solved. Please download the new version 4.0.1.

Thanks for reporting and sorry for the inconvenience

JesperLR commented 6 years ago

Awesome - it works! Thanks a lot for solving so quickly :)

ferranpons commented 6 years ago

I'm closing this issue since it's solved with the latest version 4.0.1.