mardi 5 mai 2015

Creating AmazonDynamoDBClient with AWSCredentials

We are developing a basic game for android phones and have recently switched from Eclipse IDE to Android Studios. With the switch, I was forced to move from aws-java-sdk-1.9.30 to aws-android-sdk-2.2.0.

I have attempted to update the AWS code and it is now compiling, however I have come across an issue while creating the AmazonDynamoDBClient.

This is the exception that is being thrown:

Exception in thread "main" java.lang.IllegalArgumentException: no HostnameVerifier specified

Here is where the exception is thrown (inside HTTPSURLConnection.java):

public void setHostnameVerifier(HostnameVerifier v) 
{
    if (v == null) 
    {
        throw new IllegalArgumentException("HostnameVerifier is null");
    }
    hostnameVerifier = v;
}

Here is the relevant code which seems to be causing the runtime error:

static AmazonDynamoDBClient client;
...
AWSCredentials credentials = new AWSCredentials() 
{
    @Override
    public String getAWSAccessKeyId() 
    {
        return "<KEY>";
    }

    @Override
    public String getAWSSecretKey() 
    {
        return "<SECRETKEY>";
    }
};
client = new AmazonDynamoDBClient(credentials);
...
DynamoDBMapper mapper = new DynamoDBMapper(client);
...
List<PlayersListOfActiveMatches> latestReplies = mapper.query(PlayersListOfActiveMatches.class, queryExpression);


I'm not sure if I am missing a step somewhere. If anyone can help shed some light on what may be causing the issue, I will be very thankful!

On a related note, most of the examples I have been able to find, and the examples on which I based my initial code, seem to be for the aws-java-sdk-1.9.30 jars. If anyone knows of where I can find examples that are suited for the aws-android-sdk-2.2.0 jars, it would help immensely!

Thanks for your time and help!

Mike




Aucun commentaire:

Enregistrer un commentaire