Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The import com.amazonaws.services.s3.AmazonS3ClientBuilder cannot be resolved

I am trying to access my s3 buckets from my java application, trying to implement this

https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/examples-s3-buckets.html

I've added the lib/aws-java-sdk-1.8.6.jar to my lib folder and added the dependency in my pom.xml as well.

I still get this import error

"The import com.amazonaws.services.s3.AmazonS3ClientBuilder cannot be resolved" for "import com.amazonaws.services.s3.AmazonS3ClientBuilder;"

Whereas the imports

"import com.amazonaws.services.s3.AmazonS3;" and "import com.amazonaws.services.s3.model.Bucket;" gave no errors.

Any help would be appreciated. I found some people trying to implement for Android ran in similar issues but not this exactly

like image 952
obawany Avatar asked Sep 04 '18 15:09

obawany


2 Answers

I was having the same issue, and after some research I realized that AmazonS3ClientBuilder is not part from AWS Android SDK instead of that the class is part of AWS JAVA SDK so you have to include this on your dependencies:

implementation 'com.amazonaws:aws-java-sdk:1.11.404'

like image 156
Alejandro Uribe Sánchez Avatar answered Oct 23 '22 23:10

Alejandro Uribe Sánchez


  • Definitely the dependency as mentioned in Amazon documentation did not work. The path to the dependency does not exist, in Maven central repository.

    "software.amazon.awssdk" % "aws-java-sdk" % "2.0.0"

  • The following too, did not resolve com.amazonaws.services.s3.AmazonS3ClientBuilder, though the JAR path is correct in Maven central -

    "software.amazon.awssdk" % "aws-sdk-java" % "2.1.3"

  • I had to fallback to the following as mentioned in the previous comment.

    "com.amazonaws" % "aws-java-sdk" % "1.11.465"

like image 3
Zeena Avatar answered Oct 24 '22 00:10

Zeena