After solving a JDK zero value error, now I\'m facing this one. I did a little research, but it seems I can\'t get to the point. Here is the log error:
FATA
None of these worked for me. But this did:
Change
android:src="@drawable/your_drawable"
to
app:srcCompat="@drawable/your_drawable"
In my case, the problem was wrong super-type. I added image view dynamically, and used ImageView instead of AppCompatImageView. Choosing the right super class solved the issue.
IF you're using Gradle Plugin 2.0, you need to make changes in your gradle
:
// Gradle Plugin 2.0+
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
If you are using Gradle 1.5 you’ll use instead of previus:
// Gradle Plugin 1.5
android {
defaultConfig {
// Stops the Gradle plugin's automatic rasterization of vectors
generatedDensities = []
}
// Flag to tell aapt to keep the attribute ids around
// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
Check also: Update Android Support Library to 23.2.0 cause error: XmlPullParserException Binary XML file line #17<vector> tag requires viewportWidth > 0.
Android Support Library Ref.: Support Vector Drawables and Animated Vector Drawables.
Also update Android Support dependencies from
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
to
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
as you're already using build-tools in version of 24.0.2
.
Since this page is the first result of google android.content.res.Resources$NotFoundException: File res/drawable/
, I want to share that this exception might caused by your foo.xml contains improper code.
e.g. foo.xml
:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<size android:height="@android:style/Widget.ProgressBar.Horizontal" />
<corners android:radius="5dip" />
<gradient
android:startColor="#000000"
android:centerY="0.75"
android:angle="270"
/>
</shape>
</item>
</layer-list>
This xml contains <size android:height="@android:style/Widget.ProgressBar.Horizontal" />
which compiled successfully but throws exception at Runtime, vary in different app.
In my case, the issue was about using vector drawable. The spec of the test device was Huawei EVA-L19, Android: Marshmallow
Using srcCompat
instead of src
resolved my problem.
For me the issue was while running the app on Kitkat version I got this runtime crash.
Issue:
android {
compileSdkVersion 28
defaultConfig {
//Change this to true to enable multidex support for Kitkat
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
Solution: //comment the line of vector support
android {
//Change this to true to enable multidex support for Kitkat
multiDexEnabled true
//vectorDrawables.useSupportLibrary = true
}