Using Amazon Web Service SDK for Android in Android Studio

假装没事ソ 提交于 2020-01-24 11:25:27

问题


I'm trying to make use of the AWS S3 storage to store images for a mobile app, but I'm not able to compile my app. I have the .jar files in my libs directory. In the dependencies section of my build.gradle file I have:

dependencies {       
    compile "com.amazonaws.services.s3:1.6.1"
}

I've tried every combination I can think of. com.amazonaws.services.s3:1.6.1, com.amazonaws.services:s3:1.6.1, com.amazonaws:services:1.6.1...but I always get an error about that says Could not find com.amazonaws.services.s3:1.6.1. (with whatever I put on the compile line in the error).

I can't find anything about getting this SDK to work with Android Studio and don't really know enough about Gradle to know how to get it to work. Any suggestions? Anyone already have this working?


回答1:


Let me mention an addition solution:

dependencies {
    compile 'com.amazonaws:aws-android-sdk-core:2.1.+'
    compile 'com.amazonaws:aws-android-sdk-s3:2.1.+'
    // ... and any other AWS libraries you want to include
}

You can get the specific library names to use from the SDK Setup Guide.

The advantage over jmickela's (accepted) answer is that you don't need to download the files yourself, and let Gradle handle it instead. The advantage over Krit's answer is that you can pick only the specific libraries you actually want to use (Krit's solution will download all AWS libraries).

The disadvantage of my solution in comparison with jmickela's is that you may end up with an older version of the libraries, at least for a while. For instance, right now you can download 2.1.7 on AWS's site, while Gradle gets 2.1.5.




回答2:


I got another solution which may work in your case too.

I tried

dependencies {
  compile 'com.amazonaws:aws-java-sdk:+'
}

It worked.




回答3:


Found an answer myself, leaving this here since the answer will never match search terms for this specific problem.

Follow the directions on the accepted answer here: Android Studio - Importing external Library/Jar

Like the post right below it says, you don't have to exit from Android Studio, just Build->Rebuild Project



来源:https://stackoverflow.com/questions/18481728/using-amazon-web-service-sdk-for-android-in-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!