简体   繁体   English

java.lang.NoClassDefFoundError:使用Amazon S3上传图片时Android上的Pre-Lollipop上的com.google.gson.stream.JsonReader错误

[英]java.lang.NoClassDefFoundError: com.google.gson.stream.JsonReader error on Pre-Lollipop in android while uploading image with Amazon S3

Uploading image to amazon s3 bucket working fine with android 5 and above but getting Gson Error on Pre-Lollipop. 上传图片到亚马逊s3斗与Android 5及以上工作正常,但在前棒棒糖上获得Gson错误。 Below is the code i am working with. 以下是我正在使用的代码。

Error: 错误:

 FATAL EXCEPTION: TransferSerivce-AWSTransferUpdateHandlerThread
    java.lang.NoClassDefFoundError: com.google.gson.stream.JsonReader
    at com.amazonaws.util.json.GsonFactory$GsonReader.<init>(GsonFactory.java:50)
    at com.amazonaws.util.json.GsonFactory.getJsonReader(GsonFactory.java:38)
    at com.amazonaws.util.json.JsonUtils.getJsonReader(JsonUtils.java:101)
    at com.amazonaws.util.json.JsonUtils.jsonToMap(JsonUtils.java:127)
    at com.amazonaws.util.json.JsonUtils.jsonToMap(JsonUtils.java:166)
    at com.amazonaws.mobileconnectors.s3.transferutility.TransferRecord.updateFromDB(TransferRecord.java:134)
    at com.amazonaws.mobileconnectors.s3.transferutility.TransferDBUtil.getTransferById(TransferDBUtil.java:669)
    at com.amazonaws.mobileconnectors.s3.transferutility.TransferService.execCommand(TransferService.java:284)
    at com.amazonaws.mobileconnectors.s3.transferutility.TransferService$UpdateHandler.handleMessage(TransferService.java:224)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.os.HandlerThread.run(HandlerThread.java:60)

This is the code I am using to upload the Image: 这是我用来上传图片的代码:

 ClientConfiguration clientConfig = new ClientConfiguration();
                    clientConfig.setConnectionTimeout(120000); // setting connection time out to be 2 minutes.
                    clientConfig.withConnectionTimeout(120000); // setting connection timeout to be 2 minutes.
                    AmazonS3Client awsClient = new AmazonS3Client(
                            new BasicAWSCredentials("accessKey", "secreatKey"),
                            clientConfig);
                    imagePath = "A" + "/" + compressedFile.getName();
                    TransferUtility transferUtility = new TransferUtility(awsClient, getBaseContext());
                    TransferObserver observer = null;
                    try {
                        observer = transferUtility.upload("bucket-name", imagePath, compressedFile);
                    } catch (Exception e) {

                        Log.e(Tag,""+e.toString());
                    }

the above code working fine with lollipop and above but creating issue with pre lollipop 以上代码与棒棒糖及以上工作正常,但与棒棒糖前期产生问题

added Gson Dependency too thinking that it might help. Gson Dependency也认为它可能有所帮助。 But no luck 但没有运气

Gradle Dependencies: Gradle依赖:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'

compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'commons-codec:commons-codec:1.5'
compile 'com.google.android.gms:play-services:8.4.0'

compile 'com.amazonaws:aws-android-sdk-core:2.2.14'
compile 'com.amazonaws:aws-android-sdk-cognito:2.2.14'
compile 'com.amazonaws:aws-android-sdk-s3:2.2.14'

compile 'com.android.support:multidex:1.0.1'
compile 'com.google.code.gson:gson:2.6.2' // added gson hoping 
}

searched a lot but no clue. 搜索了很多,但没有任何线索。 Any help deeply appreciated. 任何帮助深深感激。

I don't have experience with android platform. 我没有android平台的经验。 But the guide here might help you to solve the issue. 但是这里的指南可能会帮助您解决问题。 Please note the following warning mentioned in the set up guide. 请注意设置指南中提到的以下警告。

For Android, you MUST place the jar files in a directory named "libs" so that the APK packager can find them. 对于Android,您必须将jar文件放在名为“libs”的目录中,以便APK打包程序可以找到它们。 Otherwise, you will get a NoClassDefFoundError error at runtime. 否则,您将在运行时收到NoClassDefFoundError错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.NoClassDefFoundError:com / google / gson / GsonBuilder错误 - java.lang.NoClassDefFoundError: com/google/gson/GsonBuilder error 获取java.lang.NoClassDefFoundError:com / google / gson / Gson - Getting java.lang.NoClassDefFoundError: com/google/gson/Gson java.lang.NoClassDefFoundError:com / google / gson / Gson - java.lang.NoClassDefFoundError: com/google/gson/Gson Apache风暴-java.lang.NoClassDefFoundError:com / google / gson / Gson - Apache storm - java.lang.NoClassDefFoundError: com/google/gson/Gson Lotus Notes Java代理的GSON库错误-java.lang.NoClassDefFoundError:com.google.gson.JsonObject - GSON library error with Lotus Notes Java Agent - java.lang.NoClassDefFoundError: com.google.gson.JsonObject 在 aws Lambda 中运行 java jar 并出现错误 com/google/gson/JsonElement: java.lang.NoClassDefFoundError - run java jar in aws Lambda with error com/google/gson/JsonElement: java.lang.NoClassDefFoundError android studio java.lang.NoClassDefFoundError Gson - android studio java.lang.NoClassDefFoundError Gson java.lang.NoClassDefFoundError:com.google.android.gms.gcm.GoogleCloudMessaging使用java.lang.NoClassDefFoundError: - java.lang.NoClassDefFoundError: com.google.android.gms.gcm.GoogleCloudMessaging using java.lang.NoClassDefFoundError: 处理程序处理失败; 嵌套的异常是java.lang.NoClassDefFoundError:com / google / gson / Gson - Handler processing failed; nested exception is java.lang.NoClassDefFoundError: com/google/gson/Gson ZXing java.lang.NoClassDefFoundError: com/google/zxing/WriterException 错误 - ZXing java.lang.NoClassDefFoundError: com/google/zxing/WriterException Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM