Android Studio Project broken after adding Google

2019-08-30 23:19发布

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

3条回答
做自己的国王
2楼-- · 2019-08-30 23:51

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.

查看更多
老娘就宠你
3楼-- · 2019-08-30 23:59

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!

查看更多
手持菜刀,她持情操
4楼-- · 2019-08-31 00:04

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

查看更多
登录 后发表回答