androidfirebase

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


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?


Solution

  • 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.