Reputation: 499
I imported the library project following this guide: https://stackoverflow.com/a/20497933 and now I have a libs folder with my required library.
But how do I use it in my code. I can't import com.github.whateverlibrary
and I can't use com.mypackagename.whateverlibrary
.
How do I reference this local library in my project?
Edit:
My settings.gradle file:
include ':libs:MyLibrary'
My app.gradle file:
compile fileTree(include: ['MyLibrary'], dir: 'libs')
Upvotes: 1
Views: 766
Reputation: 499
Somehow got it working. Exact steps:
testgithublibrary\library
libs\
so the full path would be AndroidStudioProjects\MyPackage\libs
and rename it to something else e.g. testlocallibrary
compile project(':libs:testlocallibrary')
to app.gradleinclude ':libs:testlocallibrary'
to settings.gradle in roottestlocallibrary\~java\com\example\mymodule\...
Upvotes: 0
Reputation: 1739
To add imports from a library listed as a dependency, use the fully qualified names for the classes. For example to import from https://github.com/bumptech/glide
you will use the names as is in the library without any modifications such as adding com.github
or com.yourpackagename
To import Glide
to your class you would use
import com.bumptech.glide.Glide;
see sample projects for better understanding
Upvotes: 1