J'ai essayé de télécharger une vidéo que j'ai prise dans un compartiment de services S3 à l'aide du kit AWS SDK.AWS SDK NoClassDefFoundError: com.amazonaws.services.s3.AmazonS3Client
c'est le code que j'ai pris de l'exemple Amazon pour le téléchargement S3. Les seules choses que je fais différemment sont:
- ne crée pas un nouveau compartiment mais réutilise celui qui existe déjà.
en utilisant un Uri prédéterminé pour le fichier où se trouve l'image.
public void uploadToS3(View v) { AmazonS3Client s3Client = new AmazonS3Client(new BasicAWSCredentials( Constants.ACCESS_KEY_ID, Constants.SECRET_KEY)); String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(fileUri, filePathColumn, null, null, null); cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String filePath = cursor.getString(columnIndex); cursor.close(); // Put the image data into S3. try { //s3Client.createBucket(Constants.getPictureBucket()); PutObjectRequest por = new PutObjectRequest( Constants.getPictureBucket(), Constants.PICTURE_NAME, new java.io.File(filePath)); // Content type is determined // by file extension. s3Client.putObject(por); } catch (Exception exception) { // displayAlert("Upload Failure", exception.getMessage()); } }
le problème est, une fois que j'essaie de créer les AmazonS3Client
, les application se bloque avec une exception noClassFound
.
voici mon Logcat:
05-17 10:42:02.555: E/AndroidRuntime(20310): FATAL EXCEPTION: main
05-17 10:42:02.555: E/AndroidRuntime(20310): java.lang.IllegalStateException: Could not execute method of the activity
05-17 10:42:02.555: E/AndroidRuntime(20310): at android.view.View$1.onClick(View.java:2154)
05-17 10:42:02.555: E/AndroidRuntime(20310): at android.view.View.performClick(View.java:2538)
05-17 10:42:02.555: E/AndroidRuntime(20310): at android.view.View$PerformClick.run(View.java:9152)
05-17 10:42:02.555: E/AndroidRuntime(20310): at android.os.Handler.handleCallback(Handler.java:587)
05-17 10:42:02.555: E/AndroidRuntime(20310): at android.os.Handler.dispatchMessage(Handler.java:92)
05-17 10:42:02.555: E/AndroidRuntime(20310): at android.os.Looper.loop(Looper.java:123)
05-17 10:42:02.555: E/AndroidRuntime(20310): at android.app.ActivityThread.main(ActivityThread.java:3691)
05-17 10:42:02.555: E/AndroidRuntime(20310): at java.lang.reflect.Method.invokeNative(Native Method)
05-17 10:42:02.555: E/AndroidRuntime(20310): at java.lang.reflect.Method.invoke(Method.java:507)
05-17 10:42:02.555: E/AndroidRuntime(20310): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
05-17 10:42:02.555: E/AndroidRuntime(20310): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
05-17 10:42:02.555: E/AndroidRuntime(20310): at dalvik.system.NativeStart.main(Native Method)
05-17 10:42:02.555: E/AndroidRuntime(20310): Caused by: java.lang.reflect.InvocationTargetException
05-17 10:42:02.555: E/AndroidRuntime(20310): at java.lang.reflect.Method.invokeNative(Native Method)
05-17 10:42:02.555: E/AndroidRuntime(20310): at java.lang.reflect.Method.invoke(Method.java:507)
05-17 10:42:02.555: E/AndroidRuntime(20310): at android.view.View$1.onClick(View.java:2149)
05-17 10:42:02.555: E/AndroidRuntime(20310): ... 11 more
05-17 10:42:02.555: E/AndroidRuntime(20310): Caused by: java.lang.NoClassDefFoundError: com.amazonaws.services.s3.AmazonS3Client
05-17 10:42:02.555: E/AndroidRuntime(20310): at com.thepoosh.aws.s3upload.android.CameraToAmazonaws3Activity.uploadToS3(CameraToAmazonaws3Activity.java:63)
05-17 10:42:02.555: E/AndroidRuntime(20310): ... 14 more
05-17 10:42:02.555: E/AndroidRuntime(20310): Caused by: java.lang.ClassNotFoundException: com.amazonaws.services.s3.AmazonS3Client in loader dalvik.system.PathClassLoader[/data/app/com.thepoosh.aws.s3upload.android-1.apk]
05-17 10:42:02.555: E/AndroidRuntime(20310): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
05-17 10:42:02.555: E/AndroidRuntime(20310): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
05-17 10:42:02.555: E/AndroidRuntime(20310): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
05-17 10:42:02.555: E/AndroidRuntime(20310): ... 15 more
problème peut-être lié à vos ressources telles que main.xml –
@omidnazifi, que voulez-vous dire? il n'y a pas de xml pour le 'AWS SDK' – thepoosh
est votre bibliothèque dans le dossier" libs "? Et correctement ajouté à votre projet? –