Picasso не будет загружать URL-адреса png - PullRequest
0 голосов
/ 26 января 2020

Я пытаюсь загрузить изображение PNG URL-адрес изображения не удается получить изображение, если загружен файл JPG, он просматривается только URL-адрес PNG не работает в Picasso. Обновил мои зависимости Gradle для зависимостей Пикассо. Я не знаю, почему не удалось загрузить один URL-адрес изображения. Я только что проверил эту ссылку "https://issuetracker.google.com/issues/36912546", но не смог ее решить. Нужна помощь Спасибо! '' '

ImageView testImageview;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main22);

    testImageview = findViewById(R.id.imageView);

    String imageUri = "http://i.imgur.com/DvpvklR.png";
    ImageView ivBasicImage = (ImageView) findViewById(R.id.imageView);
    Picasso.get().load(imageUri).into(ivBasicImage);


}
}

' '' Мой Xml код: '' '

   <?xml version="1.0" encoding="utf-8"?>
   <androidx.constraintlayout.widget.ConstraintLayout 
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   tools:context=".Main22Activity">

   <ImageView
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="220dp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:srcCompat="@drawable/suncloud" />
    </androidx.constraintlayout.widget.ConstraintLayout>

' '' Мой файл Gradle:

'' '

 apply plugin: 'com.android.application'

 android {
 compileSdkVersion 29
 buildToolsVersion "29.0.2"
 defaultConfig {
    applicationId "com.example.myjson"
    minSdkVersion 15
    targetSdkVersion 29
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

1 Ответ

0 голосов
/ 26 января 2020

Убедитесь, что у вас есть права доступа ниже, в файле манифеста.

<uses-permission android:name="android.permission.INTERNET" /> //uses not user

И попробуйте следующим образом:

 Picasso.with(getActivity()).load("http://i.imgur.com/DvpvklR.png").into(image);

А так как вы используете http, попробуйте Использование

android:usesCleartextTraffic="true"

в теге приложения вашего файла манифеста! Как я столкнулся с той же проблемой.

...