简体   繁体   中英

Android studio add libs

I use "add as library" in Android studio, and it sets "compile files('libs/XXX.jar')" in "build.gradle". But it doesn't work!!!

It cost lots of my time. At last, I modify to "compile files('XXX.jar')"

But my jar is in directory "libs" as picture shows: libs Picture

Please tell me why!

Here is the supplement picture of build.gradle

Try adding compile fileTree(dir: 'libs', include: ['*.jar']) to your Gradle file and tell me if it worked :)

or does it work but you don't understand why it works like this? Then it automatically assumes that your libraries are placed in that directory so you don't need to specify the libs/xxx.jar because it knows it should look in that directory anyways, so then it would search for libs/libs/xxx.jar instead of libs/xxx.jar. Hope that makes sense

In Android Studio click on Project Structure button to the right of Run Button,then click on the green + icon in the top right,choose Android Import Exiting Project[if the lib is .jar of .AAR choose Import . JAR or .AAR]then choose the lib and click finish,wait for gradle sync,then add the compile.Wish this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM