1

I've created an Android project in Eclipse and I would like to add the Volley library to it. Searching on the web, I've tried these approaches:

  • Copy the .jar into the libs folder and right-click and add it to build-path.
  • Open the library as an android project, mark it as library and add it as a reference in my android app.

Nothing works. I still cannot access the classes provided by the library by importing the classes like follow: com.android.volley

Someone has a solution for this ?

Yash Sampat
  • 30,051
  • 12
  • 94
  • 120
Hubert Solecki
  • 2,611
  • 5
  • 31
  • 63

2 Answers2

4

The Solution:

Try this:

  • Add volley.jar to the libs folder. Don't add it to the build path.
  • In Eclipse go to Project and make sure Build Automatically is selected.
  • Now in Project, click on Clean:

    Project -> select Clean -> select the project. 
    

As Volley doesn't have any resources like styles, layouts etc., its not necessary to reference it as a library project. The above should work, provided all steps are followed.

If this doesn't work ...

Make sure the library has not been added to the build path. If it is, then remove it. Now, try:

  • Closing and re-opening the project.
  • Restarting the IDE (last resort).
Yash Sampat
  • 30,051
  • 12
  • 94
  • 120
  • 1
    please provide some more relevant details about your project. I can't tell what you're doing wrong. I too had Eclipse Luna set up for Android and I never faced a problem like this – Yash Sampat Apr 03 '15 at 11:31
  • There no much details about that project. I've create a new android project this morning and added to it the volley.jar which was in the git repository that I've cloned from the given link: https://android.googlesource.com/platform/frameworks/volley Then I just add it the ways I explained in my post but can't access it... There is nothing more about the project. The minimum SDK targeted is 8 and the targeted SDK version is 22 – Hubert Solecki Apr 03 '15 at 11:40
  • 1
    I think that adding the library manually to the build path is a mistake. Normally that is never required, it happens automatically when Eclipse rebuilds all projects, and it works properly. – Yash Sampat Apr 03 '15 at 14:59
  • I've just found the reason. The library which is available from the Android website by downloading the Git repository isn't working. I've found a link which provides the .jar too and by simply doing what you've told me, it works perfectly. Thank you ! – Hubert Solecki Apr 03 '15 at 15:24
1

The build process for Volley has changed to Gradle. If you just want to use the library without building it, you can get the Jar from Maven or scroll down to the instructions to building it yourself lower in this answer.

Maven

An easier way to obtain the Jar file is to download it directly from Maven Central. You can find the latest version with this search:

http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.mcxiaoke.volley%22

At the time of writing the 1.0.19 version can be found here:

http://search.maven.org/remotecontent?filepath=com/mcxiaoke/volley/library/1.0.19/library-1.0.19.jar


Gradle

The new way to do it is to build the project using Gradle.

You can do this by running:

git clone https://android.googlesource.com/platform/frameworks/volley
gradle build

This will create a file in

build\intermediates\bundles\release

Then add this file into your libs folder and add it to your project.

Mahendran Candy
  • 1,114
  • 17
  • 17