Reputation: 1272
I have just recently made the transition from Eclipse to Android Studio. I have not had a problem until I tried to add Picasso to dependencies. I went to Project Structure -> Dependencies -> then clicked the '+' sign and went into Library Dependency. I scrolled down to Picasso, clicked ok, and clicked apply. However, whenever I do this it says "Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly.
To double check, I clicked on build.gradle (Module: app), went down to dependencies to see if it is there and this is what my build.gradle looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.squareup.picasso:picasso:2.3.2'
}
The error that it is saying is "Failed to find: com.squareup.picasso:picasso:2.3.2" Is there anything I'm doing wrong? I have tried to change the picasso compile line to 2.3.+ and several others but nothing works.
Upvotes: 2
Views: 6434
Reputation: 1530
i +1 archon92. good screenshots. i followed the screenshots to move .jar into libs folder. then i followed steps in accepted answer, and the errors went away. (thank you archon92 and Kenneth Streit)
Upvotes: 0
Reputation: 1272
I figured it out. I ended up copying in the jar file into the libs folder like you were saying. However, after I did that I went to Project Structure -> Dependencies -> '+' -> File Dependency. I then clicked on the Picasso Jar file and applied that. This resolved my issue and I can now use Picasso without any problems.
Upvotes: 3
Reputation: 200020
While the apply plugin: 'com.android.application'
knows how to pull in dependencies from local sources (such as jar files or the support library from the local repository), you need to declare other remote repositories by adding a repositories
section at the top level of your gradle file (i.e., directly below the apply plugin
line):
repositories {
mavenCentral()
}
Upvotes: 0
Reputation: 447
This link should help you.Follow the steps excatly as its mentioned and youll be up and running in no time.It worked for me.
Setup and use Picasso in android studio
Do this: 1)Download the jar file
2)Add compile 'com.squareup.picasso:picasso:2.3.3'
to the build.gradle file in the dependency section.(2.3.3 being the picasso version.This is subject to change as the version progresses)
3)add the jar file to your libs folder.To do this follow these steps: Click on the android icon in your project tab and in the drop down menu select "project".
Change your project structure from "Android" to "project" as shown in the screenshots.The libs folder will be visible only in the "project" structure
Once this is done,you can see the libs folder under the apps directory as shown in the screen shot. Add the picasso library here and right click on it and select "add as library".Select "Ok" in the dialog menu that appears.
Now gradle will sync again and picasso will be ready for use.
Upvotes: 2