aws / aws-sdk-java-v2

The official AWS SDK for Java - Version 2
Apache License 2.0
2.19k stars 846 forks source link

Using Apache Client Throws Verify Error in Runtime [No Documentation for Timestream using Amplify] #2573

Closed DmitriySmerchinskiy closed 3 years ago

DmitriySmerchinskiy commented 3 years ago

Hello, guys!

I use aws java 2 sdk in my android project to access timestream db features, specifically write to the timestream db. According to this documentation I use apache client, but in runtime I got verify error on apache client builder creation line.

I added it using BOM

dependencies {
   implementation platform('software.amazon.awssdk:bom:2.15.0')
   implementation 'software.amazon.awssdk:timestreamwrite'
   implementation 'software.amazon.awssdk:apache-client'
}

I also added such packaging options to avoid duplications

android {
 packagingOptions {
         exclude 'META-INF/INDEX.LIST'
         exclude 'META-INF/io.netty.versions.properties'
         exclude 'META-INF/DEPENDENCIES'

         exclude 'codegen-resources/customization.config'
         exclude 'codegen-resources/service-2.json'
         exclude 'codegen-resources/examples-1.json'
         exclude 'codegen-resources/waiters-2.json'
         exclude 'codegen-resources/paginators-1.json'
         exclude 'codegen-resources/api-2.json'
         exclude 'codegen-resources/docs-2.json'
         exclude 'codegen-resources/customization.config.out'
     }
}

So, running this code, my app crashes with Verify Error: val httpClientBuilder: ApacheHttpClient.Builder = ApacheHttpClient.builder()

StackTrace:

java.lang.VerifyError: Verifier rejected class software.amazon.awssdk.http.apache.ApacheHttpClient: void software.amazon.awssdk.http.apache.ApacheHttpClient.lambda$CesDBZD1BbE4st5txvnWxnpBCPc(org.apache.http.client.methods.HttpRequestBase) failed to verify: void software.amazon.awssdk.http.apache.ApacheHttpClient.lambda$CesDBZD1BbE4st5txvnWxnpBCPc(org.apache.http.client.methods.HttpRequestBase): [0x0] 'this' argument 'Reference: org.apache.http.client.methods.HttpRequestBase' not instance of 'Reference: org.apache.http.client.methods.AbstractExecutionAwareRequest' (declaration of 'software.amazon.awssdk.http.apache.ApacheHttpClient' appears in /data/app/com.myapp-vwXrwwFH45E6OAB9U9flRg==/base.apk!classes18.dex)
        at software.amazon.awssdk.http.apache.ApacheHttpClient.builder(ApacheHttpClient.java:133)
        at com.lobab.api.timestream.TimestreamClient$Companion.buildWriteClient(TimestreamClient.kt:127)

imports:

import software.amazon.awssdk.auth.credentials.AwsBasicCredentials
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration
import software.amazon.awssdk.core.retry.RetryPolicy
import software.amazon.awssdk.http.apache.ApacheHttpClient
import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.services.timestreamwrite.TimestreamWriteClient
import software.amazon.awssdk.services.timestreamwrite.model.*

Also, I have to note, that this project also has Amplify as a dependency, by I didn't find documentation about how to work with timestream DB using Amplify. Everywhere, Amazon recommends Amplify usage but no any documentation about how to deal with timestream using Amplify.

My environment:

debora-ito commented 3 years ago

HI @DmitriySmerchinskiy we don't have a lot of familiarity in running the Java SDK in Android environments unfortunately.

Have you reached out to the Amplify team? They maintain the projects in https://github.com/aws-amplify/. It's also a good place to ask about Timestream support.

github-actions[bot] commented 3 years ago

It looks like this issue hasn’t been active in longer than a week. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please add a comment to prevent automatic closure, or if the issue is already closed please feel free to reopen it.