Reputation: 899
I put the .jar file inside the /libs folder and added it as library, now my build.gradle file has these dependencies:
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':SmoothProgressBar')
compile 'com.squareup.picasso:picasso:2.5.0'
My manifest is like this
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.prova" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
But when i need to load an image it doesen't do anything and no error come from logcat. Here's my code:
public class MainActivity extends ActionBarActivity {
private ImageView img;
private String image = "https://i.sstatic.net/LOb1t.png";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
img = (ImageView) findViewById(R.id.image);
Picasso.with(this).setLoggingEnabled(true);
Picasso.with(this).load(Uri.parse(image)).into(img);
}
}
My layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true" />
</RelativeLayout>
In Eclipse worked fine without any problem. Thanks in advance.
EDIT: This is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.enrico.prova"
minSdkVersion 15
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.5.0'
}
EDIT2: Logcat:
02-23 16:41:36.857 28865-28865/com.example.enrico.prova D/Picasso﹕ Main created [R1] Request{http://www.online-image-editor.com//styles/2014/images/example_image.png}
02-23 16:41:36.858 28865-28884/com.example.enrico.prova D/Picasso﹕ Dispatcher enqueued [R1]+0ms
02-23 16:41:36.876 28865-29238/com.example.enrico.prova D/Picasso﹕ Hunter executing [R1]+16ms
02-23 16:41:36.883 28865-28884/com.example.enrico.prova D/Picasso﹕ Dispatcher batched [R1]+25ms for error
02-23 16:41:37.112 28865-28884/com.example.enrico.prova D/Picasso﹕ Dispatcher delivered [R1]+254ms
02-23 16:41:37.112 28865-28865/com.example.enrico.prova D/Picasso﹕ Main errored [R1]+255ms
Upvotes: 1
Views: 2792
Reputation: 3574
OK, this sounds super obvious but was my issue...Does your phone have internet? Is it connected? Just test if all else fails as sometimes it's the simple things that we overlook.
Upvotes: 0
Reputation: 13223
You have your permissions inside the <application>
. They should go inside the <manifest>
outside <application>
.
Upvotes: 3
Reputation: 2292
hello please try since you have to pass a uri to the Picasso load
load(Uri.parse(image))
Can you please post update code..with Uri.parse..because as you can see it works in a project of mine
Upvotes: 1
Reputation: 1933
Why don't you try with Maven Central instead of jar like,
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':SmoothProgressBar')
compile 'com.squareup.picasso:picasso:2.5.0'
and may be instead getApplicationContext()
, you should use just this
.
Upvotes: 1