Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

Can't get image into Android Studio

+10 votes

This isn't really a question, but something that I found out the hard way. If you try to bring an image into the app and get an error message like this:

Rendering Problems
Failed to convert @drawable/(file name) into a drawable

you will want to check the filename. Android Studio doesn't seem to like files that have dashes in the filename. Replacing spaces with underscores seems to be fine, and it accepted a file with capital letters in the title, but it did not like dashes at all.

asked Mar 28, 2015 in Spring 2015 by Andrew Shearouse (100 points)

2 Answers

+5 votes
I think this problem could also be caused if your image file isn't in a supported format.  PNG is usually a good choice.
answered Mar 30, 2015 by Forrest Stonedahl (100 points)
+2 votes
Oops. Submitted too fast - as soon as I tried to compile, I got an error that the filename can only have lowercase letters. So capitals did not work after all!
answered Mar 28, 2015 by Andrew Shearouse (100 points)
Also not a question, but the best way I found to resize the image is to directly edit the layout_width and layout_height values to <int>dp.

At first I tried editing the scaleX/scaleY or maxWidth/Height but those didn't work at all.