Code Monkey home page Code Monkey logo

Comments (10)

heckchuckman avatar heckchuckman commented on September 16, 2024 1

Hi @tolu360

Fantastic work! I can confirm that going through all of the dependencies that reference com.google.android.gms:play-services-base need to me the same version. After that all methods seem to be working!

Thanks!

from react-native-google-places.

rasmniel avatar rasmniel commented on September 16, 2024 1

Hello @tolu360
Thanks for the effort and apologies for the lack of response.
Your solution has indeed fixed the problem by forcing the dependencies to the appropriate version.

Thanks again for solving our problem and keep up the good work - Cheers!

from react-native-google-places.

tolu360 avatar tolu360 commented on September 16, 2024

Hey @rasmniel, so if I gather correctly, the error is only thrown when you call getAutocompletePredictions ()? All other APIs work just fine?

The first place I would look would be the versions of Google PlayServices being pulled in by react-native-fcm and react-native-google-places (10.2.0). This bug may well be a conflict in GPS versions from the two packages.

First ensure you are on the very latest release of this package (2.1.0) and try to lock the gcm requirement for react-native-fcm to the same 10.2.0 in your android/app/build.gradle by adding the force flag:

dependencies {
     // other packages here
     compile ('com.google.android.gms:play-services-gcm:10.2.0') {
        force = true;
     }
}

Clean your project and try to build and run again:

cd android && ./gradlew clean

Lets start here and see if anything changes. Cheers!

from react-native-google-places.

rasmniel avatar rasmniel commented on September 16, 2024

I have the latest version (2.1.0) of the react-native-google-places package. The dependency line you suggested wasn't even in the android/app/build.gradle dependency list - let alone the force = true flag, albeit both packages still worked fine when installed separately. I'm guessing a default version was chosen.

In this configuration gradlew assembleDebug ends abruptly with

:app:processDebugGoogleServices
Found com.google.android.gms:play-services-gcm:10.2.0, but version 10.0.1 is needed for the google-services plugin.
:app:processDebugGoogleServices FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-ols/com.google.gms.google-services/) or updating the version of com.google.android.gms to 10.0.1.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

It seems that some Google Services dependency is certainly the culprit here. The odd thing is that the version required is lower than the forced one. Perhaps either of the packages are attempting to lock the version internally?

This is the android/app/build.gradle dependency list:

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.facebook.react:react-native:+"
    compile "com.android.support:appcompat-v7:23.0.1"
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile project(':react-native-google-places')
    compile project(':react-native-fcm')
    compile ('com.google.android.gms:play-services-gcm:10.2.0') {
        force = true;
    }
}

I'm hoping this sheds a bit more light on the issue. Thanks for the snappy response!

from react-native-google-places.

tolu360 avatar tolu360 commented on September 16, 2024

So it is most likely Play Services version conflict, but if we are trying to lock down versions to 10.2.0, you can't pull in [email protected] at the same time. Try instead:

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.facebook.react:react-native:+"
    compile "com.android.support:appcompat-v7:23.0.1"
    compile 'com.google.firebase:firebase-core:10.2.0'
    compile project(':react-native-google-places')
    compile project(':react-native-fcm')
    compile ('com.google.android.gms:play-services-gcm:10.2.0') {
        force = true;
    }
}

Once again, clean and try to build again.

from react-native-google-places.

rasmniel avatar rasmniel commented on September 16, 2024

I didn't even consider the firebase-core version to be incorrect here. I'm assuming it was just installed automatically with react-native-fcm, so I didn't consider the 10.0.1 version to be anything but coincidental.

I've updated the firebase version to 10.2.0, cleaned, and built from scratch. This time there are no error messages in the build process and the app runs smoothly, but the same RNGooglePlaces.getAutocompletePredictions error still persists, when attempting to invoke the function.

I apologize for being unable to produce any more helpful error messages.

from react-native-google-places.

tolu360 avatar tolu360 commented on September 16, 2024

Hey @rasmniel, is this still an issue? Perhaps we should re-visit it.

Can you get stack trace for the crash from Android Studio or from your terminal? To copy logs from the terminal, build and run your app normally, then run on your terminal the command below just before you invoke getAutocompletePredictions() or do your autocomplete search :

adb logcat

As soon as the crash occurs, you can Ctrl + C to stop the logs and look for lines starting from the crash to the reported causes (may report more than one) e.g.

Fatal Exception: java.lang.RuntimeException: Could not invoke RNGooglePlaces.getAutocompletePredictions ......

Caused by ....

Caused by .....

Getting the monitor logs would help us unravel this. Cheers.

from react-native-google-places.

rasmniel avatar rasmniel commented on September 16, 2024

Hello @tolu360
It is indeed still an issue for us.
As I have little to no experience using adb logcat, I will just send you the bulk of it. I tried to cut the most relevant part from the point you mentioned, but notice that the error does in fact not start with words Fatal Exception.

...
05-23 20:16:40.989  3544  3873 E unknown:React: Exception in native call
05-23 20:16:40.989  3544  3873 E unknown:React: java.lang.RuntimeException: Could not invoke RNGooglePlaces.getAutocompletePredictions
05-23 20:16:40.989  3544  3873 E unknown:React:         at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:359)
05-23 20:16:40.989  3544  3873 E unknown:React:         at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:141)
05-23 20:16:40.989  3544  3873 E unknown:React:         at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
05-23 20:16:40.989  3544  3873 E unknown:React:         at android.os.Handler.handleCallback(Handler.java:751)
05-23 20:16:40.989  3544  3873 E unknown:React:         at android.os.Handler.dispatchMessage(Handler.java:95)
05-23 20:16:40.989  3544  3873 E unknown:React:         at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
05-23 20:16:40.989  3544  3873 E unknown:React:         at android.os.Looper.loop(Looper.java:154)
05-23 20:16:40.989  3544  3873 E unknown:React:         at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
05-23 20:16:40.989  3544  3873 E unknown:React:         at java.lang.Thread.run(Thread.java:761)
05-23 20:16:40.989  3544  3873 E unknown:React: Caused by: java.lang.reflect.InvocationTargetException
05-23 20:16:40.989  3544  3873 E unknown:React:         at java.lang.reflect.Method.invoke(Native Method)
05-23 20:16:40.989  3544  3873 E unknown:React:         at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:345)
05-23 20:16:40.989  3544  3873 E unknown:React:         ... 8 more
05-23 20:16:40.989  3544  3873 E unknown:React: Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zzbxn;
05-23 20:16:40.989  3544  3873 E unknown:React:         at com.google.android.gms.location.places.AutocompletePredictionBuffer.get(Unknown Source)
05-23 20:16:40.989  3544  3873 E unknown:React:         at com.google.android.gms.location.places.AutocompletePredictionBuffer.get(Unknown Source)
05-23 20:16:40.989  3544  3873 E unknown:React:         at com.google.android.gms.common.data.zzb.next(Unknown Source)
05-23 20:16:40.989  3544  3873 E unknown:React:         at com.arttitude360.reactnative.rngoogleplaces.RNGooglePlacesModule.getAutocompletePredictions(RNGooglePlacesModule.java:291)
05-23 20:16:40.989  3544  3873 E unknown:React:         ... 10 more
05-23 20:16:40.989  3544  3873 E unknown:React: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.internal.zzbxn" on path: DexPathList[[zip file "/data/app/com.eventapp-2/base.apk"],nativeLibraryDirectories=[/data/app/com.eventapp-2/lib/arm, /system/fake-libs, /data/app/com.eventapp-2/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
05-23 20:16:40.989  3544  3873 E unknown:React:         at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
05-23 20:16:40.989  3544  3873 E unknown:React:         at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
05-23 20:16:40.989  3544  3873 E unknown:React:         at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
05-23 20:16:40.989  3544  3873 E unknown:React:         ... 14 more
...

There's plenty of output above this part, which also mentions RNGooglePlaces in it, but I will omit it for now for the sake of brevity. If you need more output or more details, let me know.

Thanks for your continued assistance. Cheers!

from react-native-google-places.

tolu360 avatar tolu360 commented on September 16, 2024

Hey @rasmniel, so this issue has been a very tricky one to debug remotely even with the stack trace, I have had to set up a sample app to reproduce your issues - and, yes I was able to reproduce it. And yes, it was just a case of Google API versions clashing all over the place.

My fix should work as long as you keep watching the libraries you are using in your project for updates and changes and acting accordingly.

TL:DR - Every Google API you use must pull in the same version of Google Play Services.

To fix things now, simply update your ./android/app/build.gradle to match mine as shown below:

android {
    ------
    buildToolsVersion "25.0.1"
    -----
    -----
}

dependencies {
    compile project(':react-native-google-places')
    compile project(':react-native-fcm')
    compile ('com.google.firebase:firebase-messaging:10.2.0') {
        force = true;
    }
    compile ('com.google.firebase:firebase-core:10.2.0') {
        force = true;
    }
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:25.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
}

Don't forget to slot in other dependencies unique to your project!

Do a cd android && ./gradlew clean, rebuild your project and profit!

Cheers!

from react-native-google-places.

tolu360 avatar tolu360 commented on September 16, 2024

@rasmniel - Feel free to re-open this if you still can't make it work. Cheers!

from react-native-google-places.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.