Unable to resolve host "www.googleapis.com":No address associated with hostname Android Studio Messanger Project

Viewed 7388

I started making my own massaging service with google firebase. But when i try to run my application and want to create a new user i always get this exception: "error:An internal error has occurred. [ Unable to resolve host "www.googleapis.com":No address associated with hostname ]"

This is my code that addds a user to my database:

private void createUser(String email, String text) {
        auth.createUserWithEmailAndPassword(email, text).addOnCompleteListener(task -> {
            if (task.isSuccessful()) {
                Log.d("testRegister", "User erstellt");
                uploadImage();
            } else {
                if (task.getException().getMessage().equals("The email address is badly formatted.")) {
                    Toast.makeText(RegisterActivity.this, "Ungültige Email-Adresse", Toast.LENGTH_SHORT).show();
                } else if (task.getException().getMessage().equals("The email address is already in use by another account.")){
                    Toast.makeText(RegisterActivity.this, "Email-Adresse wird bereits verwendet", Toast.LENGTH_SHORT).show();
                } else if (task.getException().getMessage().equals("The given password is invalid. [ Password should be at least 6 characters ]")) {
                    Toast.makeText(RegisterActivity.this, "Password muss mindestens 6 Zeichen lang sein", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(RegisterActivity.this, "Unbekannter Fehler aufgetreten", Toast.LENGTH_SHORT).show();
                    Log.d("testRegister", "error:" + task.getException().getMessage());
                }
            }
        });
    }

I tried using the admin sdk and declaring an FirebaseApp object but still got the error...

Any ideas what i can do?

5 Answers

I also experience the same thing a while ago. I was able to fix it by syncing the gradle and turn on your smartphone internet as it requires internet connection.

Click File >>> Sync Project with Gradle Files

And Done. Build and Run your app now, it should do the work.

I had the same error because of a VPN use (Internet Private Network in my case).

I resolved this error through the following steps:

  1. Ensure strong Internet Connectivity

  2. Stop the AVD and Close the Mobile GUI which is running.

  3. Wipe Data from the AVD Manager

  4. Cool Boot from the AVD Manager

  5. Run the App

Just check your internet connection on your device.

I experienced the same problem a while ago and I simply solved it by turning on my internet connection on my device.

Thank you.

I was getting the same error with Firestore(Flutter) I uninstall app from mobile and run again, it starts working fine,

Related