android – Trying to get the inputted adress latitude and longitutde-ThrowExceptions

Exception or error:

I really hope that someone can help me with this. I am trying get the longitude and latitude from the address that the user inputs(Ex: 1888 NW 14th Ave Miami FL 33189) and save that addresses longitude and latitude in the geofire firebase. I tried this code below but it’s not saving anything. Please tell me what I’m doing wrong and how could I fix this. Thanks in advance

 your_address =  (EditText)findViewById(;
        your_city =  (EditText)findViewById(;
        your_state =  (EditText)findViewById(;
        your_zipcode =  (EditText)findViewById(;

        final FirebaseAuth firebaseAuth = FirebaseAuth.getInstance();
        final FirebaseUser firebaseUser = firebaseAuth.getCurrentUser();

        String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
        DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference().child("Uzers/location");
        DatabaseReference update = rootRef.child("Uzers").child(uid);
        String address = your_address.getText().toString();
        String city = your_city.getText().toString();
        String state = your_state.getText().toString();
        String zipcode = your_zipcode.getText().toString();

        GeoFire geoFire = new GeoFire(rootRef);

        Geocoder geocoder = new Geocoder(getBaseContext(), Locale.getDefault());

        List<Address> addressList;
        double lat=0;
        double lang=0;

        try {
            addressList = geocoder.getFromLocationName(address+city+state+zipcode, 1);
            Address location=addressList.get(0);

            geoFire.setLocation(uid, new GeoLocation(lat, lang), new GeoFire.CompletionListener() {
                public void onComplete(String key, DatabaseError error) {
                    if (error != null) {

                        System.err.println("There was an error saving the location to GeoFire: " + error);
                    } else {
                        System.out.println("Location saved on server successfully!");
        } catch (IOException e) {
            System.err.println("There was an error saving the location to GeoFire: " + e);


Error Message

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *