Android Studio Project broken after adding Google Volley

扶醉桌前 提交于 2019-12-25 04:15:30

问题


I added Google volley to my app project. However, now I can no longer compile it. When trying to Gradle sync I constantly get the following error message:

Error:Cause: failed to find target with hash string 'android-22' in: /Users/Tom/Library/Android/sdk

Open Android SDK Manager

I opened the SDK Manager and installed everything that was requested. However, I'm still getting the same error.

I did the following:

  1. git clone volley project
  2. In Studio: File -> New -> New Module -> Import Gradle Project -> selected volley folder
  3. Added compile project('volley') to the settings.gradle in the dependency part

回答1:


Error:Cause: failed to find target with hash string 'android-22'

it means that the version of volley you imported has as dependency Android-22 (Android 5.1.1). Open the Android SDK manager and install it. After this error should disapper




回答2:


I use Google's official volley library in my projects by the following steps:

  1. Git clone, of course :)
  2. Copy & paste its android folder into \app\src\main\java\com folder path of my project
  3. If my project compileSdkVersion 23, then add useLibrary 'org.apache.http.legacy' into build.gradle file

Hope this helps!




回答3:


In a comment, @Toom mentioned to use

dependencies {
    ...
    compile 'com.mcxiaoke.volley:library:1.+'
}

This workaround was very useful at the time. Maybe there were many bugs in the official back in the day, I don't know, because I used this. Yet, it appears that this has been deprecated at 1.0.19 (Readme was updated in 2017). The repo can be found at https://github.com/mcxiaoke/android-volley . Today, the official is at 1.1.0 and documentation can be found at https://developer.android.com/training/volley/ . Other answers explain how to use this in your project.



来源:https://stackoverflow.com/questions/33043625/android-studio-project-broken-after-adding-google-volley

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