Location selection on my phone will not open

I made a place picker app. It opens on my emulator (API 19) and my friends phone (android 6.0), but it just opens black activity for me, which closes right after (my phone is also android 6.0), with this error:

 E/AndroidRuntime: FATAL EXCEPTION: main
                                               Process: com.google.android.gms.ui, PID: 19226
                                               Theme: themes:{}
                                               java.lang.RuntimeException: Unable to resume activity {com.google.android.gms/com.google.android.location.places.ui.placepicker.PlacePickerActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void com.google.maps.api.android.lib6.impl.bq.o()' on a null object reference
                                                   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3169)
                                                   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3200)
                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2541)
                                                   at android.app.ActivityThread.access$900(ActivityThread.java:159)
                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353)
                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                   at android.os.Looper.loop(Looper.java:148)
                                                   at android.app.ActivityThread.main(ActivityThread.java:5504)
                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void com.google.maps.api.android.lib6.impl.bq.o()' on a null object reference
                                                   at com.google.maps.api.android.lib6.impl.da.b(:com.google.android.gms.DynamiteModulesB:96)
                                                   at com.google.android.gms.maps.internal.z.onTransact(:com.google.android.gms.DynamiteModulesB:73)
                                                   at android.os.Binder.transact(Binder.java:387)
                                                   at url.b(:com.google.android.gms:233)
                                                   at upa.a(:com.google.android.gms:127)
                                                   at omy.b(:com.google.android.gms:340)
                                                   at omu.a(:com.google.android.gms:143)
                                                   at com.google.android.gms.maps.MapView.a(:com.google.android.gms:7332)
                                                   at amzd.onResume(:com.google.android.gms:92)
                                                   at com.google.android.chimera.FragmentProxy.onResume(:com.google.android.gms:433)
                                                   at gm.a(:com.google.android.gms:12120)
                                                   at gm.a(:com.google.android.gms:1286)
                                                   at gm.a(:com.google.android.gms:1268)
                                                   at gm.p(:com.google.android.gms:2153)
                                                   at gm.a(:com.google.android.gms:12126)
                                                   at gm.a(:com.google.android.gms:1286)
                                                   at gm.a(:com.google.android.gms:1268)
                                                   at gm.p(:com.google.android.gms:2153)
                                                   at gc.e(:com.google.android.gms:11223)
                                                   at bxe.superOnResumeFragments(:com.google.android.gms:2406)
                                                   at com.google.android.chimera.Activity.onResumeFragments(:com.google.android.gms:384)
                                                   at com.google.android.chimera.Activity.publicOnResumeFragments(:com.google.android.gms:389)
                                                   at bxe.e(:com.google.android.gms:469)
                                                   at gc.onPostResume(:com.google.android.gms:511)
                                                   at bxe.superOnPostResume(:com.google.android.gms:2401)
                                                   at com.google.android.chimera.Activity.onPostResume(:com.google.android.gms:375)
                                                   at bxc.onPostResume(:com.google.android.gms:183)
                                                   at com.google.android.chimera.Activity.publicOnPostResume(:com.google.android.gms:380)
                                                   at bxe.onPostResume(:com.google.android.gms:460)
                                                   at android.app.Activity.performResume(Activity.java:6385)
                                                   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3158)
                                                   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3200) 
                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2541) 
                                                   at android.app.ActivityThread.access$900(ActivityThread.java:159) 
                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353) 
                                                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                   at android.os.Looper.loop(Looper.java:148) 
                                                   at android.app.ActivityThread.main(ActivityThread.java:5504) 
                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

code:

  PLACE_PICKER_REQUEST = 199;
        PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
        Context context = this;
        try {
            startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
        } catch (GooglePlayServicesRepairableException e) {
            e.printStackTrace();
        } catch (GooglePlayServicesNotAvailableException e) {
            e.printStackTrace();
        }

Result Code:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_PICKER_REQUEST) {
        if (resultCode == RESULT_OK) {
            Place place = PlacePicker.getPlace(data, this);
            Toast.makeText(this,  place.getAddress(), Toast.LENGTH_LONG).show();

            String toastMsg = String.format("Place: %s", place.getName());
           // Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show();
            TextView lbl_coordenadas = (TextView) findViewById(R.id.lbl_coordenadas);
            coordenadas=""+place.getName();
            lbl_coordenadas.setText("Coordenadas: "+coordenadas);
        }
    }
}

Does anyone have any idea what this might be? Thank you in advance.

+6
source share

Source: https://habr.com/ru/post/1017179/


All Articles