This code causes force close exception on Emulator(API 18) and works in ASUS Nexus 7(API 21)
<View
android:layout_width="400dp"
android:layout_height="2dp"
android:layout_marginTop="30dp"
android:background="@color/light_gray" />
If I am replacing @color/light_gray
with #EBEBEB
works perfectly on both device.
Exception is
Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f080060 a=-1 r=0x7f080060}
So I moved to drawable on following code,
<Button
android:layout_width="wrap_content"
android:layout_marginTop="30dp"
android:layout_height="wrap_content"
android:ems="10"
android:background="@drawable/login_btn_selector"
android:text="Login"
android:id="@+id/btnLogin" />
This one throws following exception,
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-hdpi-v4/login_btn_selected.xml from drawable resource ID #0x7f020095
So I tried to place the login_btn_selected.xml
in res/drawable-hdpi-v4/
folder, Then it says duplicate file occur between res/drawable-hdpi/
and res/drawable-hdpi-v4/
, So I removed it from res/drawable-hdpi/
, Then again same resource not found exception in v4 folder,
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-hdpi-v4/login_btn_selected.xml from drawable resource ID #0x7f020095
So finally I came to SO.
The problem is,
I want to know is this problem in emulator only or in real device too.
If in real device too means how can I overcome this?
I want to use
@color/light_gray
instead of hard coding, Also I want to use drawable selectors.
NOTE: I have deleted and recreated the Emulator, no use. I have tested on API 19 emulator also, same issue.
Any solution will be highly appreciable.