java.lang.NoClassDefFoundError:com.amazonaws.services.s3.AmazonS3Client

时间:2014-02-02 08:16:29

标签: java android amazon-web-services amazon-s3

我已经在我的eclipse(ADT eclipse)中导入了S3Uploader示例,我正在尝试运行它。

我已经导入了项目,然后添加了以下的罐子 项目>属性> java build path>添加罐子

02/02/2014 01:24 PM 6,376,630 aws-android-sdk-1.7.1.1-debug.jar 02/02/2014 01:14 PM 281,550 aws-android-sdk-1.7.1.1-s3.jar 02/02/2014 01:24 PM 5,587,005 aws-android-sdk-1.7.1.1.jar

项目编译并构建正常。但是当我运行它时会产生以下异常

02-02 13:39:03.151: E/dalvikvm(20716): Could not find class 'com.amazonaws.services.s3.AmazonS3Client', referenced from method com.amazonaws.demo.s3uploader.S3UploaderActivity.<init>
02-02 13:39:03.151: W/dalvikvm(20716): VFY: unable to resolve new-instance 40 (Lcom/amazonaws/services/s3/AmazonS3Client;) in Lcom/amazonaws/demo/s3uploader/S3UploaderActivity;
02-02 13:39:03.151: D/dalvikvm(20716): VFY: replacing opcode 0x22 at 0x0004
02-02 13:39:03.151: D/dalvikvm(20716): VFY: dead code 0x0006-0018 in Lcom/amazonaws/demo/s3uploader/S3UploaderActivity;.<init> ()V
02-02 13:39:03.161: W/dalvikvm(20716): VFY: unable to find class referenced in signature (Lcom/amazonaws/services/s3/AmazonS3Client;)
02-02 13:39:03.161: W/dalvikvm(20716): VFY: unable to resolve static field 33 (US_WEST_2) in Lcom/amazonaws/regions/Regions;
02-02 13:39:03.161: D/dalvikvm(20716): VFY: replacing opcode 0x62 at 0x0005
02-02 13:39:03.161: D/dalvikvm(20716): VFY: dead code 0x0007-003c in Lcom/amazonaws/demo/s3uploader/S3UploaderActivity;.onCreate (Landroid/os/Bundle;)V
02-02 13:39:03.161: D/AndroidRuntime(20716): Shutting down VM
02-02 13:39:03.161: W/dalvikvm(20716): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
02-02 13:39:03.161: E/AndroidRuntime(20716): FATAL EXCEPTION: main
02-02 13:39:03.161: E/AndroidRuntime(20716): java.lang.NoClassDefFoundError: com.amazonaws.services.s3.AmazonS3Client
02-02 13:39:03.161: E/AndroidRuntime(20716):    at com.amazonaws.demo.s3uploader.S3UploaderActivity.<init>(S3UploaderActivity.java:45)
02-02 13:39:03.161: E/AndroidRuntime(20716):    at java.lang.Class.newInstanceImpl(Native Method)
02-02 13:39:03.161: E/AndroidRuntime(20716):    at java.lang.Class.newInstance(Class.java:1409)
02-02 13:39:03.161: E/AndroidRuntime(20716):    at android.app.Instrumentation.newActivity(Instrumentation.java:1040)
02-02 13:39:03.161: E/AndroidRuntime(20716):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1777)
02-02 13:39:03.161: E/AndroidRuntime(20716):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893)
02-02 13:39:03.161: E/AndroidRuntime(20716):    at android.app.ActivityThread.access$1500(ActivityThread.java:135)
02-02 13:39:03.161: E/AndroidRuntime(20716):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
02-02 13:39:03.161: E/AndroidRuntime(20716):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 13:39:03.161: E/AndroidRuntime(20716):    at android.os.Looper.loop(Looper.java:150)
02-02 13:39:03.161: E/AndroidRuntime(20716):    at android.app.ActivityThread.main(ActivityThread.java:4385)
02-02 13:39:03.161: E/AndroidRuntime(20716):    at java.lang.reflect.Method.invokeNative(Native Method)
02-02 13:39:03.161: E/AndroidRuntime(20716):    at java.lang.reflect.Method.invoke(Method.java:507)
02-02 13:39:03.161: E/AndroidRuntime(20716):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
02-02 13:39:03.161: E/AndroidRuntime(20716):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
02-02 13:39:03.161: E/AndroidRuntime(20716):    at dalvik.system.NativeStart.main(Native Method)

我也查看了AWS SDK NoClassDefFoundError: com.amazonaws.services.s3.AmazonS3Client

它还说明了我已做过的事情。

我该如何解决?

2 个答案:

答案 0 :(得分:1)

您可能需要按照our blog中列出的步骤导出库以便在Android应用程序中使用。

答案 1 :(得分:1)

我使用以下内容解决了错误:

创建了一个libs文件夹(libs而不是lib)并将所有jar文件复制到该文件夹​​。它工作正常。 ADT自动将构建时依赖性放在libs文件夹内的jar中。它工作正常。

最初我的jars在lib文件夹中,我对它有明确的依赖性。所以它在编译时工作但是这些libs没有打包在APK里面。这很奇怪,我也读到了这个地方。