I came across a similar issue while following a related tutorial http://mobile.awsblog.com/post/Tx1U4RV2QI1MVWS/Amazon-DynamoDB-on-Mobile-Part-1-Loading-Data https://github.com/awslabs/aws-sdk-android-samples/tree/master/DynamoDBMapper_UserPreference
I'm using the latest version of Android Studio (0.8.1) and AWS SDK for Android (1.7.1.1). It looks like you're using the wrong package path.
For
import com.amazonaws.services.dynamodbv2.model.DynamoDBAttribute;
import com.amazonaws.services.dynamodbv2.model.DynamoDBHashKey;
import com.amazonaws.services.dynamodbv2.model.DynamoDBMapper;
import com.amazonaws.services.dynamodbv2.model.DynamoDBScanExpression;
import com.amazonaws.services.dynamodbv2.model.DynamoDBTable;
import com.amazonaws.services.dynamodbv2.model.PaginatedScanList;
you're using com.amazonaws.services.dynamodbv.model
when it should be com.amazonaws.services.dynamodbv2.datamodeling
. For more proof/documentation about the packages you can look at dynmodbv2 here to see that they are not deprecated. Change your package path to reflect this:
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
import com.amazonaws.services.dynamodbv2.datamodeling.PaginatedScanList;
and you should hopefully only need to use one of the following:
- aws-android-sdk-VERSION.jar. Contains all necessary files (including third-party dependencies) for all supported AWS services. All class files were compiled without the debug option.
- aws-android-sdk-VERSION-debug.jar. Contains all files (including third-party dependencies) necessary for debugging. The code was compiled with the debug option on with all symbols retained.
For more on the jars in the AWS SDK for Android see the official documentation here
Other Potential Issues
(Should only be relevant for AWS SDK for 1.7.1.1 and below if the bug doesn't get fixed in the next rev)
My issue was different in that even though I had the correct package path as per documentation, Android Studio's Intellij couldn't find dynamodbv2.datamodeling
that is, when typing import com.amazonaws.services.dynamodbv2.
it didn't suggest datamodeling, only utility and model. Trying import com.amazonaws.services.dynamodbv2.*
didn't fix the issue either. Because of this it seems that the datamodeling package isn't wrapped into the two above mentioned packages which in theory are supposed to be all encompassing. To get datamodeling and fix the issue I had in regards to the same objects not being found (DynamoDBAttribute, DynamoDBHashKey, etc.) I had to add as library/file dependencies aws-android-sdk-1.7.1.1-ddb-mapper.jar
and aws-android-sdk-1.7.1.1-ddb.jar
and cleaned my project at which point Intellij could see datamodeling when typing import and the sample project could compile.
I imagine you know how to import libraries in your platform as you mentioned importing, but make sure it's only the individual files you need and you don't include aws-android-sdk-1.7.1.1-debug.jar
or aws-android-sdk-1.7.1.1.jar
with them. So for example, my Android Studio module gradle build file dependencies looks like:
dependencies {
compile files('libs/aws-android-sdk-1.7.1.1-ddb-mapper.jar')
compile files('libs/aws-android-sdk-1.7.1.1-ddb.jar')
compile files('libs/aws-android-sdk-1.7.1.1-autoscaling.jar')
compile files('libs/aws-android-sdk-1.7.1.1-cloudwatch.jar')
compile files('libs/aws-android-sdk-1.7.1.1-core.jar')
compile files('libs/aws-android-sdk-1.7.1.1-ec2.jar')
compile files('libs/aws-android-sdk-1.7.1.1-elb.jar')
compile files('libs/aws-android-sdk-1.7.1.1-s3.jar')
compile files('libs/aws-android-sdk-1.7.1.1-sdb.jar')
compile files('libs/aws-android-sdk-1.7.1.1-ses.jar')
compile files('libs/aws-android-sdk-1.7.1.1-sns.jar')
compile files('libs/aws-android-sdk-1.7.1.1-sqs.jar')
compile files('libs/aws-android-sdk-1.7.1.1-sts.jar')
}
The issue I had seems to be a bug where ddb and ddb-mapper weren't included in what should be the all encompassing aws-android-sdk-1.7.1.1-debug.jar
and aws-android-sdk-1.7.1.1.jar
. As such, I have reported on GitHub (https://github.com/aws/aws-sdk-android/issues/18) and hopefully the next rev will fix this issue and it will no longer be relevant and you should only need aws-android-sdk-1.7.1.1-debug.jar
or aws-android-sdk-1.7.1.1.jar