Android的 - 毕加索Android Studio中不加载 [英] Android - Picasso in Android Studio doesn't load

查看:308
本文介绍了Android的 - 毕加索Android Studio中不加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我Android Studio中是新所以probabibly它的东西错了,我没有,但我不明白。我把.jar文件的/ libs文件夹内并将其添加为图书馆,现在我的build.gradle文件具有这些依赖关系:

 编译文件树(导演:'库',包括:['的* .jar'])
编译com.android.support:appcompat-v7:21.0.3
编制项目(':SmoothProgressBar')
编译com.squareup.picasso:毕加索:2.5.0

我的表现是这样的。

 <清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=com.example.prova>    <应用
        机器人:allowBackup =真
        机器人:图标=@的mipmap / ic_launcher
        机器人:标签=@字符串/ APP_NAME
        机器人:主题=@风格/ AppTheme>        <使用许可权的android:NAME =android.permission.INTERNET对/>
        <使用许可权的android:NAME =android.permission.ACCESS_NETWORK_STATE/>
        <使用许可权的android:NAME =android.permission.WRITE_EXTERNAL_STORAG​​E/>
        <使用许可权的android:NAME =android.permission.READ_EXTERNAL_STORAG​​E/>        <活动
            机器人:名字=。MainActivity
            机器人:标签=@字符串/ APP_NAME>
            &所述;意图滤光器>
                <作用机器人:名字=android.intent.action.MAIN/>                <类机器人:名字=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;
    < /用途>< /清单>

但是,当我需要加载图像它doesen't做任何事情,任何错误都来自logcat中。这里是我的code:

 公共类MainActivity扩展ActionBarActivity {私人ImageView的IMG;私人字符串形象=htt​​p://i.stack.imgur.com/LOb1t.png;    @覆盖
    保护无效的onCreate(捆绑savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.activity_main);
    IMG =(ImageView的)findViewById(R.id.image);    Picasso.with(本).setLoggingEnabled(真);
    Picasso.with(本).load(Uri.parse(图片))成(IMG)。
    }}

我的布局:

 <的RelativeLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent>    < ImageView的
        机器人:ID =@ + ID / IMG
        机器人:layout_width =match_parent
        机器人:layout_height =match_parent
        机器人:layout_centerInParent =真/>< / RelativeLayout的>

在Eclipse中没有任何问题,工作得很好。
先谢谢了。

编辑:
这是我的build.gradle

 应用插件:'com.android.application安卓{
    compileSdkVersion 21
    buildToolsVersion21.1.2    defaultConfig {
        的applicationIDcom.example.enrico.prova
        15的minSdkVersion
        targetSdkVersion 21
        版本code 1
        的versionName1.0
    }
    buildTypes {
        发布 {
            minifyEnabled假
            proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
        }
    }
}依赖{
    编译文件树(导演:'库',包括:['的* .jar'])
    编译com.android.support:appcompat-v7:21.0.3
    编译com.squareup.picasso:毕加索:2.5.0
}

EDIT2:
logcat的:

  16 02-23:41:36.857 28865-28865 / com.example.enrico.prova D /毕加索:主要创建[R1]请求{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 /毕加索:调度排队[R1] + 0毫秒
02-23 16:41:36.876 28865-29238 / com.example.enrico.prova D /毕加索:猎人执行[R1] + 16ms的
02-23 16:41:36.883 28865-28884 / com.example.enrico.prova D /毕加索:调度批[R1] + 25ms的错误
02-23 16:41:37.112 28865-28884 / com.example.enrico.prova D /毕加索:调度交付[R1] + 254ms
02-23 16:41:37.112 28865-28865 / com.example.enrico.prova D /毕加索:主要出错[R1] + 255毫秒


解决方案

您有您的内部权限<应用> 。他们应该去里面的<清单> 之外<应用方式>

I'm new in Android Studio so probabibly it's something wrong I did but I don't understand. 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 = "http://i.stack.imgur.com/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

解决方案

You have your permissions inside the <application>. They should go inside the <manifest> outside <application>.

这篇关于Android的 - 毕加索Android Studio中不加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆