Reputation: 3423
I've moved my project from ant build to gradle build, but I can't get it to use the jars from my libs directory.
app/libs
directorycompile fileTree(dir: 'libs', include: '*.jar')
to the app/build.gradleUnfortunately, it didn't work, the classes from those jars are not available during runtime.
I have ran the gradle
from command line with debug option, to check the whole output, and it's clear to me that they are not processed.
I know I'm doing something wrong, but I have no idea what. I thought that in my other projects I have used it multiple times, but after going through every one of them, I can see that I have never used jars
loaded from libs
directory.
What am I missing?
Upvotes: 2
Views: 1569
Reputation: 6153
I assume you are using Android Studio and you have a .jar file which you want to include in your project : (get rid of any changes you made in that matter- I just opened a new empty project:)
Edited:
if you are not using Gui then add this to your Gradle under dependencies
compile fileTree(include: '*.jar', dir: 'libs')
and make sure you have libs directory on root(with your jar in it) finally run a clean build
Upvotes: 1
Reputation: 11
First you are missing the brackets in this line fileTree(dir: 'libs', include: '*.jar')
.
You need to write like this
compile fileTree(dir: 'libs', include: ['*.jar'])
Then make sure that you have added your .jar files to Project Structure->app->dependencies->Plus button -> add file dependency.
Upvotes: 1