If you're importing a library as source code into a Gradle-based
project, then at the moment there's no super-easy way to do it (sorry, it's
on the to-do list, see https://code.google.com/p/android/issues/detail?id=62122)
so you'll have to author your own build file for the library. Actually, it
might be easier to use the New Module wizard to set up the build file and
directory structure, then you can trim it down and copy the files over.
This set of steps should get you up and running. It seems like a lot of
steps but it should hopefully go pretty quick.
- From the File menu, choose New Module...
- From the wizard that comes up, choose Android Library
- From the next page of the wizard, give it the module name
HoloCircularProgressBar, and uncheck the options for Create custom
launcher icon and Create activity.
- Click Finish on the wizard.
It should add the new module to your project, so you'll end up with
something like this:
- Delete everything inside the src/main folder.
- Now copy
from the HoloCircularProgressBar source into the
- Rename the
src folder that you just copied into
- The New Module wizard left some things in the
file in your
HoloCircularProgresBar module/directory (make
sure you're editing that one, not the one for your main app module) we
don't need. Remove the
dependencies block and the
At this point you should hopefully be able to build successfully. Now if
you want to actually use the module:
- Go to File > Project Structure... > Modules >
Your main module > Dependencies.
- Click on the + button to add a dependency, choose Module
dependency, and select
HoloCircularProgressBar from the
import statements and usages of the library should
work, and you should be good to go.