Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoSuchFieldError in Android Studio #1180

Closed
LittleHans8 opened this issue Apr 1, 2019 · 5 comments
Closed

java.lang.NoSuchFieldError in Android Studio #1180

LittleHans8 opened this issue Apr 1, 2019 · 5 comments
Labels
guidance Question that needs advice or information.

Comments

@LittleHans8
Copy link

Expected Behavior

No java.lang.NoSuchFieldError should be thrown.

Current Behavior

 java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; in class Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; or its superclasses (declaration of 'org.apache.http.conn.ssl.AllowAllHostnameVerifier' appears in /system/framework/framework.jar!classes3.dex)
        at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:146)

Possible Solution

see : using-apache-httpclient-with-android-sdk-23-nosuchmethod

Steps to Reproduce (for bugs)

I want to generate an S3Client and the operation is failed, this is my code:

Region region = Region.US_EAST_1;
AwsSessionCredentials awsCreds = AwsSessionCredentials.create(ACCESS_KEY, SECRET_ACCESS_KEY, "");
S3Client s3 = S3Client.builder()
 .credentialsProvider(StaticCredentialsProvider.create(awsCreds))
 .region(region).build();

Your Environment

  • AWS Java SDK version used: software.amazon.awssdk:s3:2.5.20
  • JDK version used: 1.8.0_152-release-1248-b01 amd64
  • Operating System and version: Windows 10 10.0
  • Android Studio version: 3.3.2
  • Android compileSdkVersion : 28
@zoewangg
Copy link
Contributor

zoewangg commented Apr 2, 2019

@LittleHans8 Are you using AWS Java SDK v2 on Andriod? I'm not sure if it would work though.

We have a designated mobile SDK. https://docs.aws.amazon.com/sdk-for-android/index.html

@LittleHans8
Copy link
Author

@zoewangg Yes,I am using AWS Java SDK v2 on Andriod , sdk-for-android is work for me, but it can't custom endpoint.

@zoewangg
Copy link
Contributor

zoewangg commented Apr 4, 2019

Unfortunately, we won't be able to fix Apache http client for Android use case. Can you try with http url connection client?

        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>url-connection-client</artifactId>
            <version>${awsjavasdk.version}</version>
        </dependency>
S3Client.builder()
.httpClientBuilder(UrlConnectionHttpClient.builder())
.build()

@LittleHans8
Copy link
Author

It works! Thanks, but need add javax.xml.stream:stax-api and com.bea.xml.stream:org.motechproject.com.bea.xml.stream lib to 'build.gradle' file.

@Cornflower1991
Copy link

It works! Thanks, but need add javax.xml.stream:stax-api and com.bea.xml.stream:org.motechproject.com.bea.xml.stream lib to 'build.gradle' file.

`javax.xml.stream:stax-api and com.bea.xml.stream:org.motechproject.com.bea.xml.stream version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

4 participants