0

I am having problem regarding getting the items into DynamoDB table. I tried the code i wrote but the Apps crashed and i am lost of what have I Below are may codes for references.

AddItem method

public void AddItem()
    {
        DynamoDB db = new DynamoDB(client);
                Table table = db.getTable(tableName);

        Map<String, AttributeValue> add = new HashMap<String, AttributeValue>();

        // Build the item
        Item item = new Item()
            .withPrimaryKey("id_Tesis", 206)
            .withString("author_Tesis", "20-Bicycle 206")
            .withString("program_Tesis", "206 description")
            .withString("super_Tesis", "Hybrid")
            .withString("title_Tesis", "Brand-Company C")   
            .withInt("title_Tesis", 2004);

        // Write the item to the table 
        table.putItem(item);

    }

MainActivity.java

public void onClick(View v) 
            {
                 dbClient.AddItem();
                 Log.i("sys", "Good");  
            }

LOGCAT ERROR:

06-04 13:26:26.749: E/AndroidRuntime(17001): FATAL EXCEPTION: main
06-04 13:26:26.749: E/AndroidRuntime(17001): Process: com.afdal.ftsmtheses, PID: 17001
06-04 13:26:26.749: E/AndroidRuntime(17001): java.lang.NoClassDefFoundError: com.amazonaws.services.dynamodbv2.document.DynamoDB
06-04 13:26:26.749: E/AndroidRuntime(17001):    at com.afdal.ftsmtheses.Update_Table.AddItem(Update_Table.java:54)
06-04 13:26:26.749: E/AndroidRuntime(17001):    at com.afdal.ftsmtheses.Admin_Page$2.onClick(Admin_Page.java:70)
06-04 13:26:26.749: E/AndroidRuntime(17001):    at android.view.View.performClick(View.java:4478)
06-04 13:26:26.749: E/AndroidRuntime(17001):    at android.view.View$PerformClick.run(View.java:18698)
06-04 13:26:26.749: E/AndroidRuntime(17001):    at android.os.Handler.handleCallback(Handler.java:733)
06-04 13:26:26.749: E/AndroidRuntime(17001):    at android.os.Handler.dispatchMessage(Handler.java:95)
06-04 13:26:26.749: E/AndroidRuntime(17001):    at android.os.Looper.loop(Looper.java:149)
06-04 13:26:26.749: E/AndroidRuntime(17001):    at android.app.ActivityThread.main(ActivityThread.java:5257)
06-04 13:26:26.749: E/AndroidRuntime(17001):    at java.lang.reflect.Method.invokeNative(Native Method)
06-04 13:26:26.749: E/AndroidRuntime(17001):    at java.lang.reflect.Method.invoke(Method.java:515)
06-04 13:26:26.749: E/AndroidRuntime(17001):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-04 13:26:26.749: E/AndroidRuntime(17001):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
06-04 13:26:26.749: E/AndroidRuntime(17001):    at dalvik.system.NativeStart.main(Native Method)
mkobit
  • 43,979
  • 12
  • 156
  • 150
Batman
  • 101
  • 1
  • 11

1 Answers1

0

The reason you see that error is because the library aws-java-sdk-dynamodb isn't exported to the APK. If you use eclipse, please check your project properties -> Java build path -> Order and export.

The DynamoDB document API is offered by AWS Java SDK, but is unavailable in AWS SDK for Android. If you plan to use an SDK on Android, please consider AWS SDK for Android which is fully tested on Android and is optimized for Android in terms of library size, method count number, and performance. See http://aws.amazon.com/mobile/sdk/ for more information.

Yangfan
  • 1,866
  • 1
  • 11
  • 13