Search code examples
androidamazon-web-servicesamazon-dynamodbnoclassdeffounderroramazon-sns

NoClassDefFoundError while creating AmazonSNSClient using AWS SDK for Java


In my Android app I want to work with Amazon SNS

AmazonSNSClient snsClient = new AmazonSNSClient(new ClasspathPropertiesFileCredentialsProvider());

But I got this error:

Caused by: java.lang.NoClassDefFoundError: com.amazonaws.services.sns.AmazonSNSClient

I use Eclipse Luna and installed AWS Toolkit for Eclipse. In Java Build Path of my Project, I selected "Add Library" -> "AWS SDK for Java".

I don't know how to solve this problem. Please help me!


Solution

  • AWS has an SDK specifically for Android https://aws.amazon.com/mobile/sdk/.

    A getting started guide, including how to set up in Eclipse (Or use Android Studio / Maven) is available at http://docs.aws.amazon.com/mobile/sdkforandroid/developerguide/setup.html.

    I also highly suggest not embedding credentials in your application when releasing it, as it is highly insecure and anyone could decompile your app and steal your credentials. Instead I suggest looking at Amazon Cognito for authentication (it's in the guide linked above).