&引用;提供的键元素与架构不匹配;在AWS Android SDK的示例中

&引用;提供的键元素与架构不匹配;在AWS Android SDK的示例中,android,amazon-web-services,amazon-s3,amazon-dynamodb,Android,Amazon Web Services,Amazon S3,Amazon Dynamodb,我遵循AWS Android SDK的指示, 但是当我执行mapper.save()方法时,它总是抛出 07-10 11:47:28.966:E/AndroidRuntime(2030): com.amazonaws.AmazonServiceException:提供的键元素不 match the schema (Service: AmazonDynamoDBv2; Status Code: 400; 错误代码:ValidationException;请求ID: 这是我的桌子: 和我的书模

我遵循AWS Android SDK的指示, 但是当我执行
mapper.save()
方法时,它总是抛出

07-10 11:47:28.966:E/AndroidRuntime(2030):

com.amazonaws.AmazonServiceException:提供的键元素不

match the schema (Service: AmazonDynamoDBv2; Status Code: 400;
错误代码:ValidationException;请求ID:

这是我的桌子:

和我的书模型代码:

package com.example.qingzhong.awssample.dbresources;


import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBAttribute;
import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBHashKey;
import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBIndexHashKey;
import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBIndexRangeKey;
import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBTable;

/**
 * Created by qingzhong on 10/7/15.
 */



@DynamoDBTable(tableName = "Books")
public class Book {
    private String title;
    private String author;
    private int price;
    private String isbn;
    private Boolean hardCover;

    @DynamoDBIndexRangeKey(attributeName = "Title")
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @DynamoDBIndexHashKey(attributeName = "Author")
    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    @DynamoDBAttribute(attributeName = "Price")
    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    @DynamoDBHashKey(attributeName = "ISBN")
    public String getIsbn() {
        return isbn;
    }

    public void setIsbn(String isbn) {
        this.isbn = isbn;
    }

    @DynamoDBAttribute(attributeName = "Hardcover")
    public Boolean getHardCover() {
        return hardCover;
    }

    public void setHardCover(Boolean hardCover) {
        this.hardCover = hardCover;
    }
}
我在MainActivity中的代码,只需使用mapper.save()方法,没有什么特别之处:

我不知道出了什么问题,因为所有必需的属性都添加到Book.class中,实际上我是按照AWS Mobile SDK的说明操作的


我终于找到了答案,链接中的图片:

实际上是误导性的,如果您想在代码中使用ISBN作为哈希键,则需要指定

1.选择哈希作为主键类型。 2.对于哈希属性名称,确保选择了字符串并输入ISBN。单击“继续”。


很抱歉给您带来了困惑。我同意这是误导性的,我们将很快纠正文件。谢谢你指出这一点。那么你改变了什么呢?选择哈希作为主键类型。