Исключение файла скольжения не найдено из базы данных Firebase - PullRequest
0 голосов
/ 24 апреля 2019

Я использую библиотеку Glide для загрузки изображений, сохраненных в моей базе данных Firebase в реальном времени. Я могу видеть изображения и текст заголовка, загруженные из моего приложения в БД, однако они не загружают изображения в представлении приложения, а отображают текст из БД. Когда я жестко запрограммировал метод glide с URL-адресом изображения, оно показывалось в приложении, но не смог загрузить его из кода Glide.with (context) .load ((UploadInfo.getImageURL ())). Into (holder.imageView); .

Я использую телефон Samsung 2016 Galaxy A5 для тестирования. Пробовал перезапуск и чистую сборку в студии.

// Журналы ошибок

2019-04-24 01:14:04.748 6713-6713/com.xyz W/Glide: Load failed for com.google.android.gms.tasks.zzu@7b60e with size [1080x600]
    class com.bumptech.glide.load.engine.GlideException: Failed to load resource
    There were 3 causes:
    java.io.FileNotFoundException(/com.google.android.gms.tasks.zzu@7b60e (No such file or directory))
    java.io.FileNotFoundException(No such file or directory)
    java.io.FileNotFoundException(No such file or directory)
     call GlideException#logRootCauses(String) for more detail
      Cause (1 of 3): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, LOCAL
    There was 1 cause:
    java.io.FileNotFoundException(/com.google.android.gms.tasks.zzu@7b60d5e (No such file or directory))
     call GlideException#logRootCauses(String) for more detail
        Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
    There was 1 cause:
    java.io.FileNotFoundException(/com.google.android.gms.tasks.zzu@7b60e (No such file or directory))
     call GlideException#logRootCauses(String) for more detail
          Cause (1 of 1): class java.io.FileNotFoundException: /com.google.android.gms.tasks.zzu@7b60d5e (No such file or directory)
      Cause (2 of 3): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class android.os.ParcelFileDescriptor, LOCAL
    There was 1 cause:
    java.io.FileNotFoundException(No such file or directory)
     call GlideException#logRootCauses(String) for more detail
        Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
    There was 1 cause:
    java.io.FileNotFoundException(No such file or directory)
     call GlideException#logRootCauses(String) for more detail
          Cause (1 of 1): class java.io.FileNotFoundException: No such file or directory
      Cause (3 of 3): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class android.content.res.AssetFileDescriptor, LOCAL
    There was 1 cause:
    java.io.FileNotFoundException(No such file or directory)
     call GlideException#logRootCauses(String) for more detail
        Cause (1 of 1): class java.io.FileNotFoundException: No such file or directory


//Glide method in the below class
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder> {

    public static Context context;
    List<ImageUploadInfo> MainImageUploadInfoList;

    public RecyclerViewAdapter(Context context, List<ImageUploadInfo> TempList) {

        this.MainImageUploadInfoList = TempList;

        this.context = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_recycler_view_adapter, parent, false);

        ViewHolder viewHolder = new ViewHolder(view);

        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        ImageUploadInfo UploadInfo = MainImageUploadInfoList.get(position);

        holder.imageNameTextView.setText(UploadInfo.getImageName());

        //Loading image from Glide library.

        Glide.with(context).load((UploadInfo.getImageURL())).into(holder.imageView);
        //Glide.with(context).load("com.google.android.gms.tasks.zzu@7b60e").into(holder.imageView);
        //Glide.with(context).load("https://firebasestorage.googleapis.com/v0/b/xyz-d840c.appspot.com/o/All_Image_Uploads%2F1555878624050.jpg?alt=media&token=3b04e084-55bf-4693-9c57-db77bffaa0e8").into(holder.imageView);
    }

    @Override
    public int getItemCount() {

        return MainImageUploadInfoList.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        public ImageView imageView;
        public TextView imageNameTextView;

        public ViewHolder(View itemView) {
            super(itemView);

            imageView = itemView.findViewById(R.id.imageView);

            imageNameTextView = itemView.findViewById(R.id.ImageNameTextView);
        }
    }
}


//Gradle app file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.xyz"
        minSdkVersion 24
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'

    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-v4:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.google.firebase:firebase-core:16.0.8'

    implementation 'com.google.firebase:firebase-storage:16.1.0'
    implementation 'com.google.firebase:firebase-auth:16.2.1'
    implementation 'com.firebase:firebase-client-android:2.4.0'
    implementation 'com.google.firebase:firebase-database:16.1.0'
    //For Gallery Images
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.+'
    implementation 'id.zelory:compressor:2.0.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.squareup.okhttp:okhttp:2.5.0'


    //https://github.com/firebase/FirebaseUI-Android
    // FirebaseUI for Firebase Realtime Database
    implementation 'com.firebaseui:firebase-ui-database:4.3.2'

    // FirebaseUI for Cloud Firestore
    implementation 'com.firebaseui:firebase-ui-firestore:4.3.2'

    // FirebaseUI for Firebase Auth
    implementation 'com.firebaseui:firebase-ui-auth:4.3.2'

    // FirebaseUI for Firebase Auth (GitHub provider)
    implementation 'com.firebaseui:firebase-ui-auth-github:4.3.2'

    // FirebaseUI for Cloud Storage
    implementation 'com.firebaseui:firebase-ui-storage:4.3.2'

    //implementation 'com.google.firebase:firebase-analytics:16.4.0'

    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    //implementation 'com.google.android.gms:play-services-basement:jar:12.0.1'
    //implementation 'com.google.android.gms:play-services:12.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.6.0'
}

apply plugin: 'com.google.gms.google-services'

1 Ответ

1 голос
/ 24 апреля 2019
implementation 'com.squareup.picasso:picasso:2.71828'

Добавить заданную библиотеку в ваш Gradle и синхронизировать проект

 Picasso.get().load(UploadInfo.getImageURL()).error(R.drawable.ic_errorwhite_24dp).into(holder.imageView);

используйте Picasso вместо Glide, он автоматически поймает ошибку

...