pinkfish / flutter_places_dialog

Google places picker plugin for flutter. Opens up the google places picker on ios and android returning the chosen place back to the flutter app.
Other
44 stars 10 forks source link

java.lang.NullPointerException: intent must not be null #3

Open skillFocus16 opened 6 years ago

skillFocus16 commented 6 years ago

When the FlatButton "Pick" is clicked, maps opens and loads for like 2 seconds then nullPointerException is thrown and then the app crashes. Below is the error log:

I/System.out(25275): data is null!!!! D/AndroidRuntime(25275): Shutting down VM E/AndroidRuntime(25275): FATAL EXCEPTION: main E/AndroidRuntime(25275): Process: tz.co.naamini.app, PID: 25275 E/AndroidRuntime(25275): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=42, result=2, data=null} to activity {tz.co.naamini.app/tz.co.naamini.app.MainActivity}: java.lang.NullPointerException: intent must not be null E/AndroidRuntime(25275): at android.app.ActivityThread.deliverResults(ActivityThread.java:4215) E/AndroidRuntime(25275): at android.app.ActivityThread.handleSendResult(ActivityThread.java:4258) E/AndroidRuntime(25275): at android.app.ActivityThread.-wrap20(ActivityThread.java) E/AndroidRuntime(25275): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1583) E/AndroidRuntime(25275): at android.os.Handler.dispatchMessage(Handler.java:110) E/AndroidRuntime(25275): at android.os.Looper.loop(Looper.java:203) E/AndroidRuntime(25275): at android.app.ActivityThread.main(ActivityThread.java:6284) E/AndroidRuntime(25275): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(25275): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1094) E/AndroidRuntime(25275): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:955) E/AndroidRuntime(25275): Caused by: java.lang.NullPointerException: intent must not be null E/AndroidRuntime(25275): at com.google.android.gms.common.internal.Preconditions.checkNotNull(Unknown Source) E/AndroidRuntime(25275): at com.google.android.gms.location.places.ui.zzb.getStatus(Unknown Source) E/AndroidRuntime(25275): at com.google.android.gms.location.places.ui.PlaceAutocomplete.getStatus(Unknown Source) E/AndroidRuntime(25275): at com.example.flutterplacesdialog.FlutterPlacesDialogPlugin.onActivityResult(FlutterPlacesDialogPlugin.kt:99) E/AndroidRuntime(25275): at io.flutter.app.FlutterPluginRegistry.onActivityResult(FlutterPluginRegistry.java:194) E/AndroidRuntime(25275): at io.flutter.app.FlutterActivityDelegate.onActivityResult(FlutterActivityDelegate.java:139) E/AndroidRuntime(25275): at io.flutter.app.FlutterActivity.onActivityResult(FlutterActivity.java:128) E/AndroidRuntime(25275): at android.app.Activity.dispatchActivityResult(Activity.java:6982) E/AndroidRuntime(25275): at android.app.ActivityThread.deliverResults(ActivityThread.java:4211) E/AndroidRuntime(25275): ... 9 more Lost connection to device.

pinkfish commented 6 years ago

Usually this means you have not setup your Google services file correctly.

Did you follow the instructions for that on the Google website?

On Tue, Jun 5, 2018, 3:57 AM Namy Charles notifications@github.com wrote:

When the FlatButton "Pick" is clicked, maps opens and loads for like 2 seconds then nullPointerException is thrown and then the app crashes. Below is the error log:

I/System.out(25275): data is null!!!! D/AndroidRuntime(25275): Shutting down VM E/AndroidRuntime(25275): FATAL EXCEPTION: main E/AndroidRuntime(25275): Process: tz.co.naamini.app, PID: 25275 E/AndroidRuntime(25275): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=42, result=2, data=null} to activity {tz.co.naamini.app/tz.co.naamini.app.MainActivity}: java.lang.NullPointerException: intent must not be null E/AndroidRuntime(25275): at android.app.ActivityThread.deliverResults(ActivityThread.java:4215) E/AndroidRuntime(25275): at android.app.ActivityThread.handleSendResult(ActivityThread.java:4258) E/AndroidRuntime(25275): at android.app.ActivityThread.-wrap20(ActivityThread.java) E/AndroidRuntime(25275): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1583) E/AndroidRuntime(25275): at android.os.Handler.dispatchMessage(Handler.java:110) E/AndroidRuntime(25275): at android.os.Looper.loop(Looper.java:203) E/AndroidRuntime(25275): at android.app.ActivityThread.main(ActivityThread.java:6284) E/AndroidRuntime(25275): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(25275): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1094) E/AndroidRuntime(25275): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:955) E/AndroidRuntime(25275): Caused by: java.lang.NullPointerException: intent must not be null E/AndroidRuntime(25275): at com.google.android.gms.common.internal.Preconditions.checkNotNull(Unknown Source) E/AndroidRuntime(25275): at com.google.android.gms.location.places.ui.zzb.getStatus(Unknown Source) E/AndroidRuntime(25275): at com.google.android.gms.location.places.ui.PlaceAutocomplete.getStatus(Unknown Source) E/AndroidRuntime(25275): at com.example.flutterplacesdialog.FlutterPlacesDialogPlugin.onActivityResult(FlutterPlacesDialogPlugin.kt:99) E/AndroidRuntime(25275): at io.flutter.app.FlutterPluginRegistry.onActivityResult(FlutterPluginRegistry.java:194) E/AndroidRuntime(25275): at io.flutter.app.FlutterActivityDelegate.onActivityResult(FlutterActivityDelegate.java:139) E/AndroidRuntime(25275): at io.flutter.app.FlutterActivity.onActivityResult(FlutterActivity.java:128) E/AndroidRuntime(25275): at android.app.Activity.dispatchActivityResult(Activity.java:6982) E/AndroidRuntime(25275): at android.app.ActivityThread.deliverResults(ActivityThread.java:4211) E/AndroidRuntime(25275): ... 9 more Lost connection to device.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pinkfish/flutter_places_dialog/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/ACbmMWOuDTAUjAfBxy6tKvOI-hfIIo1Bks5t5mQ1gaJpZM4UamWV .

skillFocus16 commented 6 years ago

Yes I did. I also went through all the instructions again in case I missed anything. But the error keeps showing and crashing my app

phaugsoen commented 6 years ago

I have the same problem. When I set the apiKey I get the following error

I/System.out( 8675): Need to setup google-service.json on android
I/flutter ( 8675): Initialized api key AIzaSy********b7mU4et5Fo false

I am sure the key is correct, is used for Google maps in other places in the same app.

I have a google-services.json file for Firebase where there also is a entry w the same key as above for the map.

 "api_key": [
        {
          "current_key" : "AIzaSy*******b7mU4et5Fo"

        }
      ],
pinkfish commented 6 years ago

Weird, for the google services stuff this is reading in that file as part of the google libraries itself. Unless you are on iOS anyway... Do you have the google places api enabled in the cloud for your api key?

On Thu, 14 Jun 2018 at 04:51, Per Haugsöen notifications@github.com wrote:

I have the same problem. When I set the apiKey I get the following error

I/System.out( 8675): Need to setup google-service.json on android I/flutter ( 8675): Initialized api key AIzaSy****b7mU4et5Fo false

I am sure the key is correct, is used for Google maps in other places in the same app.

I have a google-services.json file for Firebase where there also is a entry w the same key as above for the map.

"api_key": [ { "current_key" : "AIzaSy***b7mU4et5Fo"

    }
  ],

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pinkfish/flutter_places_dialog/issues/3#issuecomment-397267343, or mute the thread https://github.com/notifications/unsubscribe-auth/ACbmMWGSYHbgnkF2DKEUAvjKuztrEx0Oks5t8k47gaJpZM4UamWV .

pinkfish commented 6 years ago

Took me a surprisingly long time to get all these bits setup when I first did it too. The errors the google libraries give when things fail is a bit difficult to decypher.

On Thu, 14 Jun 2018 at 10:48, David Bennett pinkfishfrog@gmail.com wrote:

Weird, for the google services stuff this is reading in that file as part of the google libraries itself. Unless you are on iOS anyway... Do you have the google places api enabled in the cloud for your api key?

On Thu, 14 Jun 2018 at 04:51, Per Haugsöen notifications@github.com wrote:

I have the same problem. When I set the apiKey I get the following error

I/System.out( 8675): Need to setup google-service.json on android I/flutter ( 8675): Initialized api key AIzaSy****b7mU4et5Fo false

I am sure the key is correct, is used for Google maps in other places in the same app.

I have a google-services.json file for Firebase where there also is a entry w the same key as above for the map.

"api_key": [ { "current_key" : "AIzaSy***b7mU4et5Fo"

    }
  ],

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pinkfish/flutter_places_dialog/issues/3#issuecomment-397267343, or mute the thread https://github.com/notifications/unsubscribe-auth/ACbmMWGSYHbgnkF2DKEUAvjKuztrEx0Oks5t8k47gaJpZM4UamWV .

bostrot commented 6 years ago

Just encountered the same. I guess the geocoding api (for autocomplete) had to be enabled too including setting its api key in the AndroidManifest.xml:

    <meta-data
    android:name="com.google.android.geo.API_KEY"
    android:value="YOUR_GEO_API_KEY_HERE"/>
awoisoak commented 5 years ago

On my case, besides enabling Google Maps in the developer console, I needed to enable Google Places SDK for Android too at the developer console. Thanks for the plugin!

paulblakely commented 5 years ago

+1 for @bostrot 's answer. I found that I can remove the manifest entry for "com.google.android.maps.v2.API_KEY" entirely, and use "com.google.android.geo.API_KEY" instead. Perhaps the documentation should be updated?

SijuKJ commented 5 years ago

I am also facing the same issue. I have configured Maps SDK for Android and Places SDK in https://console.cloud.google.com/ and created a API key. This API key is added in AndroidManifest.xml as meta-data. <meta-data android:name="com.google.android.geo.API_KEY" android:value="AI****UI"/> But I getting the same error. So please help me to resolve this issue.