You may be experiencing issues related to changes in ADT v22. You may find this blog post useful in correcting your problem:
Exception with android jar imported to another project
-
30-05-2022 - |
题
I am writing an android app as well as a web-based interface for a project - both of which rely on AWS (SNS, SQS and S3). I created wrapper classes for AWS (SNS, SQS and S3), made it into a Java project, exported that into a JAR file - AWSCommons.jar and am now trying to leverage this jar file for both the web-interface and the android app for my project.
I did test that I was successfully able to use AWS from within the unit tests I had in my AWSCommons project. But when I try to run my android app which uses the AWSCommons.jar jar file, I get this runtime exception:
FATAL EXCEPTION: main
E/AndroidRuntime(15957): java.lang.NoClassDefFoundError:
E/AndroidRuntime(15957): java.lang.NoClassDefFoundError: com.amazonaws.auth.BasicAWSCredentials
E/AndroidRuntime(15957): at com.raasio.communication.messaging.internet.AmazonClientManager.validateCredentialsAndInstantiateClient(AmazonClientManager.java:65)
E/AndroidRuntime(15957): at com.raasio.communication.messaging.internet.AmazonClientManager.getSnsClient(AmazonClientManager.java:54)
E/AndroidRuntime(15957): at com.raasio.communication.messaging.internet.AWSProxy.<init>(AWSProxy.java:32)
E/AndroidRuntime(15957): at com.example.raasio.Raasio.onCreate(Raasio.java:79)
E/AndroidRuntime(15957): at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime(15957): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime(15957): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
E/AndroidRuntime(15957): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
Also, this is what it reads on line 65 of my AWSCommons' AmazonClientManager.java:
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
...and i have imported the BasicAWSCredentails class as expected. Thanks for your help.
解决方案