aws-amplify / amplify-android

The fastest and easiest way to use AWS from your Android app.
https://docs.amplify.aws/lib/q/platform/android/
Apache License 2.0
237 stars 111 forks source link

Getting java.net.UnknownHostException: Unable to resolve host "cognito-idp.ap-south-1.amazonaws.com": No address associated with hostname #2864

Open Manav122000 opened 1 week ago

Manav122000 commented 1 week ago

Before opening, please confirm:

Language and Async Model

Kotlin

Amplify Categories

Authentication

Gradle script dependencies

```groovy implementation("com.amplifyframework.ui:authenticator:1.2.0") implementation("com.amplifyframework:core:1.28.1") implementation("com.amplifyframework:aws-auth-cognito:1.28.1") implementation("org.jetbrains.kotlin:kotlin-stdlib:1.8.0") implementation("com.amplifyframework:aws-api:2.19.1") ```

Environment information

``` ------------------------------------------------------------ Gradle 8.7 ------------------------------------------------------------ Build time: 2024-03-22 15:52:46 UTC Revision: 650af14d7653aa949fce5e886e685efc9cf97c10 Kotlin: 1.9.22 Groovy: 3.0.17 Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023 JVM: 1.8.0_131 (Azul Systems, Inc. 25.131-b11) OS: Mac OS X 10.16 x86_64 ```

Please include any relevant guides or documentation you're referencing

https://github.com/aws-amplify/amplify-android/issues/2542

Describe the bug

I have been getting java.net.UnknownHostException: Unable to resolve host "cognito-idp.ap-south-1.amazonaws.com": No address associated with hostname, recoverySuggestion=Sorry, we don’t have a recovery suggestion for this error. exception while trying to develop a mobile application while executing Step 6(Implement login UI).

Reproduction steps (if applicable)

No response

Code Snippet

I have been referring to this [documentation](https://docs.amplify.aws/android/start/quickstart)

Log output

``` // Put your logs below this line ```

amplifyconfiguration.json

{
  "auth": {
    "user_pool_id": "ap-south-1_************",
    "aws_region": "ap-south-1",
    "user_pool_client_id": "***************",
    "identity_pool_id": "ap-south-1:***************",
    "standard_required_attributes": [
      "email"
    ],
    "username_attributes": [
      "email"
    ],
    "user_verification_types": [
      "email"
    ],
    "password_policy": {
      "min_length": 8,
      "require_numbers": true,
      "require_lowercase": true,
      "require_uppercase": true,
      "require_symbols": true
    },
    "unauthenticated_identities_enabled": true
  },
  "data": {
    "url": "https://******************.appsync-api.ap-south-1.amazonaws.com/graphql",
    "aws_region": "ap-south-1",
    "api_key": "*************",
    "default_authorization_type": "API_KEY",
    "authorization_types": [
      "AMAZON_COGNITO_USER_POOLS",
      "AWS_IAM"
    ],
    "model_introspection": {
      "version": 1,
      "models": {
        "Todo": {
          "name": "Todo",
          "fields": {
            "id": {
              "name": "id",
              "isArray": false,
              "type": "ID",
              "isRequired": true,
              "attributes": []
            },
            "content": {
              "name": "content",
              "isArray": false,
              "type": "String",
              "isRequired": false,
              "attributes": []
            },
            "createdAt": {
              "name": "createdAt",
              "isArray": false,
              "type": "AWSDateTime",
              "isRequired": false,
              "attributes": [],
              "isReadOnly": true
            },
            "updatedAt": {
              "name": "updatedAt",
              "isArray": false,
              "type": "AWSDateTime",
              "isRequired": false,
              "attributes": [],
              "isReadOnly": true
            }
          },
          "syncable": true,
          "pluralName": "Todos",
          "attributes": [
            {
              "type": "model",
              "properties": {}
            },
            {
              "type": "auth",
              "properties": {
                "rules": [
                  {
                    "allow": "public",
                    "provider": "apiKey",
                    "operations": [
                      "create",
                      "update",
                      "delete",
                      "read"
                    ]
                  }
                ]
              }
            }
          ],
          "primaryKeyInfo": {
            "isCustomPrimaryKey": false,
            "primaryKeyFieldName": "id",
            "sortKeyFieldNames": []
          }
        }
      },
      "enums": {},
      "nonModels": {}
    }
  },
  "version": "1"
}

GraphQL Schema

```graphql // Put your schema below this line ```

Additional information and screenshots

No response

tylerjroach commented 6 days ago

Sorry if this sounds like a simple question, but does your device have internet connection? UnknownHostException will be seen when the device is completely disconnected from internet.

Another issue could be that the device time is set incorrectly, proxy is blocking url, etc.

If none of these issues are present, please reply with the amplify version being used, and code snippets to how Amplify is being configured and login code being used.