flutter_places_dialog icon indicating copy to clipboard operation
flutter_places_dialog copied to clipboard

java.lang.NullPointerException: intent must not be null

Open skillFocus16 opened this issue 7 years ago • 9 comments

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.

skillFocus16 avatar Jun 05 '18 10:06 skillFocus16

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 [email protected] 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 .

pinkfish avatar Jun 05 '18 16:06 pinkfish

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

skillFocus16 avatar Jun 06 '18 08:06 skillFocus16

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"

        }
      ],

phaugsoen avatar Jun 14 '18 11:06 phaugsoen

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 [email protected] 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 avatar Jun 14 '18 17:06 pinkfish

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 [email protected] 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 [email protected] 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 avatar Jun 14 '18 17:06 pinkfish

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"/>

bostrot avatar Jun 18 '18 10:06 bostrot

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!

awoisoak avatar Nov 29 '18 06:11 awoisoak

+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?

paulblakely avatar Dec 06 '18 20:12 paulblakely

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.

SijuKJ avatar Mar 03 '19 16:03 SijuKJ