• <bdo id='We3WV'></bdo><ul id='We3WV'></ul>

      1. <i id='We3WV'><tr id='We3WV'><dt id='We3WV'><q id='We3WV'><span id='We3WV'><b id='We3WV'><form id='We3WV'><ins id='We3WV'></ins><ul id='We3WV'></ul><sub id='We3WV'></sub></form><legend id='We3WV'></legend><bdo id='We3WV'><pre id='We3WV'><center id='We3WV'></center></pre></bdo></b><th id='We3WV'></th></span></q></dt></tr></i><div id='We3WV'><tfoot id='We3WV'></tfoot><dl id='We3WV'><fieldset id='We3WV'></fieldset></dl></div>
      2. <tfoot id='We3WV'></tfoot>

        <small id='We3WV'></small><noframes id='We3WV'>

      3. <legend id='We3WV'><style id='We3WV'><dir id='We3WV'><q id='We3WV'></q></dir></style></legend>

        基本操作中的 Android Amazon DynamoDb 错误

        时间:2023-08-29

          <i id='CGa24'><tr id='CGa24'><dt id='CGa24'><q id='CGa24'><span id='CGa24'><b id='CGa24'><form id='CGa24'><ins id='CGa24'></ins><ul id='CGa24'></ul><sub id='CGa24'></sub></form><legend id='CGa24'></legend><bdo id='CGa24'><pre id='CGa24'><center id='CGa24'></center></pre></bdo></b><th id='CGa24'></th></span></q></dt></tr></i><div id='CGa24'><tfoot id='CGa24'></tfoot><dl id='CGa24'><fieldset id='CGa24'></fieldset></dl></div>
            <tbody id='CGa24'></tbody>

          <small id='CGa24'></small><noframes id='CGa24'>

            • <legend id='CGa24'><style id='CGa24'><dir id='CGa24'><q id='CGa24'></q></dir></style></legend>

              1. <tfoot id='CGa24'></tfoot>
                  <bdo id='CGa24'></bdo><ul id='CGa24'></ul>
                • 本文介绍了基本操作中的 Android Amazon DynamoDb 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试构建一个可以与 Amazon DynamoDB 交互的简单 Android 应用程序.我已经下载了最新的 Android Studio 和 AWS 移动 SDK.我现在要做的只是在我的表客户"中插入一行.但是,当我运行该应用程序时,我遇到以下错误.如果你们能帮我看一下,我会非常感激,如果我犯了一些愚蠢的错误,我会很抱歉.(我已经按照文档设置识别池,创建新策略,将东西放入 AsyncTask..等)

                  I am trying to build a simple android app that can interact with Amazon DynamoDB. I have download the latest Android Studio and also AWS mobile SDK. What I am trying to do now is simply insert a row into my table "customer". However when I run the app I encounter the following error. Would really appreciate if you guys can help me take a look and sorry if I make some stupid mistakes.(I have follow the doc to set up identification pool, create new policy, put stuff in AsyncTask..etc)

                  谢谢,

                  错误

                  07-21 23:31:59.781    4207-4234/com.example.an.myapplication E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
                  Process: com.example.an.myapplication, PID: 4207
                  java.lang.RuntimeException: An error occured while executing doInBackground()
                          at android.os.AsyncTask$3.done(AsyncTask.java:304)
                          at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
                          at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
                          at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                          at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                          at java.lang.Thread.run(Thread.java:818)
                   Caused by: com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMappingException: No interface com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBHashKey annotation found in class class com.example.an.myapplication.customers
                          at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.needAutoGenerateAssignableKey(DynamoDBMapper.java:720)
                          at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.save(DynamoDBMapper.java:780)
                          at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.save(DynamoDBMapper.java:688)
                          at com.example.an.myapplication.MainActivity$db.doInBackground(MainActivity.java:67)
                          at com.example.an.myapplication.MainActivity$db.doInBackground(MainActivity.java:56)
                          at android.os.AsyncTask$2.call(AsyncTask.java:292)
                          at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                          at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                          at java.lang.Thread.run(Thread.java:818)
                  

                  MainActivity.java

                  package com.example.an.myapplication;
                  import android.content.Context;
                  import android.os.AsyncTask;
                  import android.support.v7.app.ActionBarActivity;
                  import android.os.Bundle;
                  import android.util.Log;
                  import android.view.Menu;
                  import android.view.MenuItem;
                  import com.amazonaws.auth.CognitoCachingCredentialsProvider;
                  import com.amazonaws.regions.Regions;
                  import com.amazonaws.services.dynamodbv2.*;
                  import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.*;
                  
                  
                  
                  public class MainActivity extends ActionBarActivity {
                  private CognitoCachingCredentialsProvider credentialsProvider;
                  private static final String TAG = MainActivity.class.getSimpleName();
                  
                  
                  @Override
                  protected void onCreate(Bundle savedInstanceState) {
                      super.onCreate(savedInstanceState);
                      setContentView(R.layout.activity_main);
                  
                      credentialsProvider = new CognitoCachingCredentialsProvider(
                              this.getApplicationContext(),    /* get the context for the current activity */
                              "us-east-1:ef8bfc69-88b7-4714-ae0a-223f08a20fe5", // Identity Pool ID
                              Regions.US_EAST_1 // Region
                      );
                      new db().execute("");
                  }
                  
                  @Override
                  public boolean onCreateOptionsMenu(Menu menu) {
                      // Inflate the menu; this adds items to the action bar if it is present.
                      getMenuInflater().inflate(R.menu.menu_main, menu);
                      return true;
                  }
                  
                  @Override
                  public boolean onOptionsItemSelected(MenuItem item) {
                      // Handle action bar item clicks here. The action bar will
                      // automatically handle clicks on the Home/Up button, so long
                      // as you specify a parent activity in AndroidManifest.xml.
                      int id = item.getItemId();
                  
                      //noinspection SimplifiableIfStatement
                      if (id == R.id.action_settings) {
                          return true;
                      }
                  
                      return super.onOptionsItemSelected(item);
                  }
                  
                  private class db extends AsyncTask<String, Void, String> {
                      @Override
                      protected String doInBackground(String... params) {
                  
                          AmazonDynamoDBClient ddbClient = new AmazonDynamoDBClient(credentialsProvider);
                          DynamoDBMapper mapper = new DynamoDBMapper(ddbClient);
                          customers customer = new customers();
                          customer.setCustomerID("GG");
                          customer.setBalance(5);
                          mapper.save(customer);
                          return "Executed";
                      }
                  
                      @Override
                      protected void onPostExecute(String result) {}
                  
                      @Override
                      protected void onPreExecute() {}
                  
                      @Override
                      protected void onProgressUpdate(Void... values) {}
                  }
                  }
                  

                  customer.java

                  package com.example.an.myapplication;
                  import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.*;
                  
                  
                  @DynamoDBTable(tableName = "customer")
                  public class customers {
                  private String id;
                  private int balance;
                  
                  @DynamoDBIndexHashKey(attributeName = "CustomerID")
                  public String getCustomerID() {
                      return id;
                  }
                  
                  public void setCustomerID(String id) {
                      this.id = id;
                  }
                  
                  @DynamoDBAttribute(attributeName = "Balance")
                  public int getBalance() {
                      return balance;
                  }
                  
                  public void setBalance(int balance) {
                      this.balance = balance;
                  }
                  }
                  

                  推荐答案

                  我终于在亚马逊支持的帮助下解决了这个问题

                  I finally fix the problem with the help of Amazon support

                  In customers.java, you don't have an attribute annotated with DynamoDBHashKey.
                  Not sure how your DynamoDB table is set up. At minimum, it needs a hash key.
                  If CustomerID is the hash key, then you need to change of the annotation of id
                  from DynamoDBIndexHashKey to DynamoDBHashKey.
                  

                  结果我使用@DynamoDBIndexHashKey 而不是@DynamoDBHashKey!改正后就可以了!

                  So it turn out I use @DynamoDBIndexHashKey instead of @DynamoDBHashKey! After correcting that it works!

                  这篇关于基本操作中的 Android Amazon DynamoDb 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:AWS DynamoDB Objective C 中的递增数字属性 下一篇:DynamoDbMapperException:没有方法注释?

                  相关文章

                  最新文章

                • <i id='rA0TT'><tr id='rA0TT'><dt id='rA0TT'><q id='rA0TT'><span id='rA0TT'><b id='rA0TT'><form id='rA0TT'><ins id='rA0TT'></ins><ul id='rA0TT'></ul><sub id='rA0TT'></sub></form><legend id='rA0TT'></legend><bdo id='rA0TT'><pre id='rA0TT'><center id='rA0TT'></center></pre></bdo></b><th id='rA0TT'></th></span></q></dt></tr></i><div id='rA0TT'><tfoot id='rA0TT'></tfoot><dl id='rA0TT'><fieldset id='rA0TT'></fieldset></dl></div>

                  <tfoot id='rA0TT'></tfoot>

                      <bdo id='rA0TT'></bdo><ul id='rA0TT'></ul>

                    1. <legend id='rA0TT'><style id='rA0TT'><dir id='rA0TT'><q id='rA0TT'></q></dir></style></legend>

                      <small id='rA0TT'></small><noframes id='rA0TT'>