I have an image that is 1900*1200 in a folder called drawable-sw600dp that id like to have used on a nexus 7. When I try to run the app the main activity the screen is white and I get the following error:
java.lang.NumberFormatException: Color value '@drawable-sw600dp/background5' must start with #
at com.android.layoutlib.bridge.impl.ResourceHelper.getColor(ResourceHelper.java:71)
at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:248)
at android.content.res.BridgeTypedArray.getDrawable(BridgeTypedArray.java:782)
Could it be that the image is too large to use? Or what could cause this error to happen?
This is in my activity_main.xml where the background is set:
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background5"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:id="@+id/MainLayout"
tools:context=".MainActivity">
In my other folders drawable-hdpi,-mdpi there is no problem. However I made the .jpg image a higher resolution and now it creates this error, thats why I suspect the high resolution is causing the issue.
Remove the '-' in the file name.
NOTE: '-' is not a valid file-based resource name character: File-based resource names must contain only lowercase a-z, 0-9, or underscore
As mentioned by android doc jpg is not supported. Use png instead:
Some people have mentioned restarting Eclipse has worked, but that didn’t work for me.
Instead, I found that I had to simply rename the image file so that it did NOT start with a number. All icons in the Android Developer Icon Pack start with a number, and I had just copied the one over. It appears that if the file starts with a number, it is assumed to be the start of a hexadecimal color value, and hence looks for the # symbol.
working with: Eclipse Juno 3.7.2, Android SDK 21.1