0

Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_ico_barcode.xml from Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class Button

Cannot find @drawable/ic_ico_barcode, because of the drawableLeft in the button below, but it works for example on Android 7.1

Drawables are in folder "drawable" only. UseSupportLibrary is set to true, gradle version is new. How can I fix it?

<Button
            android:id="@+id/button6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@+id/button7"
            android:layout_alignLeft="@+id/button7"
            android:layout_alignStart="@+id/button7"
            android:layout_marginBottom="11dp"
            android:width="210dp"
            android:background="@color/GSWhite"
            android:drawableLeft="@drawable/ic_ico_barcode"
            android:onClick="onScanClick"
            android:paddingLeft="20dp"
            android:paddingRight="25dp"
            android:text="SKENOVAT"
            android:textColor="@color/GSGreen"
            android:textSize="19dp" />

Gradle version 4.1

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.greenscan.app.greenscan"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:25.0.0'
    compile 'com.android.support:support-vector-drawable:25.0.0'
    compile 'me.dm7.barcodescanner:zbar:1.9.8'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile 'io.reactivex.rxjava2:rxjava:2.1.3'
    compile 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
    compile 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.0.0'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'commons-codec:commons-codec:1.10'
    compile('com.afollestad:bridge:5.1.2') {
        exclude group: 'org.json', module: 'json'
    }
    compile 'com.android.support:multidex:1.0.0'
    testCompile 'junit:junit:4.12'
}
mare.zim
  • 199
  • 3
  • 12

1 Answers1

0

drawableLeft and drawableRight does not work even with support library for below Android 5.0 version.

From Google: As of Android Support Library 23.3.0, support vector drawables can only be loaded via app:srcCompat or setImageResource()..
http://android-developers.blogspot.ru/2016/02/android-support-library-232.html

In my situation, I have made a compound view containing FrameLayout and FrameLayout contains Button and AppCompactImageView. Compound View example

or you can use a single xxxhdpi image instead of vector drawable.

Harish Gyanani
  • 1,366
  • 2
  • 22
  • 43