Jasper Jasper - 1 month ago 13
Android Question

Amazon Cognito Error : Unable to resolve host cognito-identity.us-east-1.amazonaws.com

Trying to get a file hosted on s3 using Cognito (in a Android App) as follows:

....
AmazonS3 s3 = new AmazonS3Client(getCredentials(MyActivity.this));
S3Object object = s3.getObject(new GetObjectRequest("mybucket", "myfile"));
....

public static CognitoCachingCredentialsProvider getCredentials(Context ctx)
{
CognitoCachingCredentialsProvider cognitoProvider = new CognitoCachingCredentialsProvider(
ctx,
"us-east-1:xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx", /* Identity Pool ID */
Regions.US_EAST_1 /* Region */
);
return cognitoProvider;
}


This Error is shown:

Unable to execute HTTP request: Unable to resolve host "cognito-identity.us-east-1.amazonaws.com": No address associated with hostname
: I/AmazonHttpClient(3427): java.net.UnknownHostException: Unable to resolve host "cognito-identity.us-east-1.amazonaws.com": No address associated with hostname
: I/AmazonHttpClient(3427): at java.net.InetAddress.lookupHostByName(InetAddress.java:400)
: I/AmazonHttpClient(3427): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)


what could be wrong?

Answer

You might have forgotten to include the following permission:

<uses-permission android:name="android.permission.INTERNET" />

Please see Set Up the SDK for Android for further details.