问题
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:
- git clone volley project
- In Studio: File -> New -> New Module -> Import Gradle Project -> selected volley folder
- Added
compile project('volley')to thesettings.gradlein 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:
- Git clone, of course :)
- Copy & paste its
androidfolder into\app\src\main\java\comfolder path of my project - If my project
compileSdkVersion 23, then adduseLibrary 'org.apache.http.legacy'intobuild.gradlefile
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