I've created a new Android project using the default wizard in Android Studio. Compiled, and deployed the app to my device. All is well.
Now I want to import an external library that is available on Maven. (http://square.github.io/picasso/). I went to module properties, and added a Maven library. It shows up correctly in the list of dependencies. In addition, it shows up in the editor and I can correctly use it in code.
However, at compile time, I get a Gradle error: unable to find class
Any ideas?
As of version 0.8.9, Android Studio supports the Maven Central Repository by default. So to add an external maven dependency all you need to do is edit the module's build.gradle file and insert a line into the dependencies section like this:
You will see a message appear like 'Sync now...' - click it and wait for the maven repo to be downloaded along with all of its dependencies. There will be some messages in the status bar at the bottom telling you what's happening regarding the download. After it finishes this, the imported JAR file along with its dependencies will be listed in the External Repositories tree in the Project Browser window, as shown below.
Some further explanations here: http://developer.android.com/sdk/installing/studio-build.html
Android Studio 3
The answers that talk about Maven Central are dated since Android Studio uses JCenter as the default repository center now. Your project's build.gradle file should have something like this:
So as long as the developer has their Maven repository there (which Picasso does), then all you would have to do is add a single line to the dependencies section of your app's build.gradle file.
Try
itext
. Add dependency to yourbuild.gradle
for latest as of this postNote: special version for android, trailing "g":
I am using the springframework android artifact as an example
open build.gradle
Then add the following at the same level as apply plugin: 'android'
you can also use this notation for maven artifacts
Your IDE should show the jar and its dependencies under 'External Libraries' if it doesn't show up try to restart the IDE (this happened to me quite a bit)
here is the example that you provided that works