1

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!

8
  • Have you written an import statement for that package and class? Commented Aug 20, 2015 at 9:25
  • @deepu513 What do you mean? This line "import com.amazonaws.services.sns.AmazonSNSClient;" ? Of course yes. Commented Aug 20, 2015 at 9:33
  • The error is on that line only, it is not able to import the SDK. Commented Aug 20, 2015 at 9:35
  • @deepu513 I don't understand the problem. What is the reason? How to fix it? Commented Aug 20, 2015 at 9:36
  • Go to your project folder and then search for "libs" folder, it might be inside the app directory or build directory and paste your jar file there and restart eclipse. Commented Aug 20, 2015 at 9:39

1 Answer 1

2

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).

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you very much. It works. I have to create a credentials: AWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey). Should I hide the accessKey and secretKey and how?
Instead of using BasicAWSCredentials, use CognitoCachingCredentialsProvider. It requires you to set up a a Cognito Identity Pool on the console. Instructions can be found here docs.aws.amazon.com/mobile/sdkforandroid/developerguide/…. Glad your making progress!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.