I'm a newcomer to Android Studio development, and I'm currently following an online tutorial to make a messenger app.
I've followed the steps of this tutorial, and it now needs me to download the Library files for Smack API & GSON, and add the .jar
files to the libs
folder in my project.
With this done, I right-clicked the files in the directory and clicked Add as library
(the tutorial says to do Build Path -> Add to Build Path
, but this doesn't seem to be an option in this version of Android Studio).
At this point, the project directory menu sidebar looks like this:
From here, I tried to rebuild the project but was met with the following error:
I've not been able to find a way around this error at all, and don't know enough about Android Studio to know if this is an issue with the IDE or the package itself. I've had a look around S/O but none of the posts seem to describe the same issue, or offer any solutions to similar issues that appear to work for this too.
If anyone has run into this before, or if it is a common Android Studio problem, would you be able to advise me on how to resolve it please? Very frustrating when I just want to get on with learning how to code for Android!
Any help massively appreciated, thanks in advance!
Mark
Here is best solution for importing any jar, arr libs
allprojects {
repositories {
flatDir {
dirs 'libs'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
....
}
You do not need to add repeatable lines with libs file name.
if you are a new to android studio, you can check the project structure from android by tapping drop-down menu.
did you try
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
}
in your build.graddle file of app module
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With