Android PhotoView Library Error inflating class

466 views Asked by At

I use PhotoView in my recycler view and get error when inflate view on adapter:

public PostViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
    View view = 
        LayoutInflater.from(context).inflate(R.layout._post, viewGroup, false);
    return new PostViewHolder(view);
}

This not related to multidex. This error on all android version.

Build error is :

android.view.InflateException: Binary XML file line #10 in ..:layout/_post: Binary XML file line #10 in ..4:layout/_post: Error inflating class com.github.chrisbanes.photoview.PhotoView
Caused by: android.view.InflateException: Binary XML file line #10 in ...:layout/_post: Error inflating class com.github.chrisbanes.photoview.PhotoView
Caused by: java.lang.ClassNotFoundException: com.github.chrisbanes.photoview.PhotoView

my view file is :

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical">
    <com.github.chrisbanes.photoview.PhotoView
        android:id="@+id/row_image"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@mipmap/ic_launcher"
        />
</android.support.constraint.ConstraintLayout>

and gradle file :

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "*****"
        minSdkVersion 21
        targetSdkVersion 28
        multiDexEnabled true
        versionCode 1
        versionName "1.1"
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

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'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation('com.squareup.picasso:picasso:2.71828') {
        exclude group: 'com.android.support'
        exclude module: ['exifinterface', 'support-annotations']
    }
    implementation 'com.github.f0ris.sweetalert:library:1.5.1'
    implementation group: 'net.lingala.zip4j', name: 'zip4j', version: '1.3.1'
    implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'

    implementation 'com.google.firebase:firebase-core:16.0.9'
    implementation 'com.google.firebase:firebase-messaging:18.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.github.chrisbanes:PhotoView:1.2.6'
    implementation 'com.android.support:multidex:1.0.3'
}

repositories {
    mavenCentral()
}

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

There are 0 answers