Android Studio: Layout editor preview: Custom Views not rendering properly (resource not found)

5,702 views
Skip to first unread message

Streets Of Boston

unread,
Aug 5, 2013, 11:54:04 AM8/5/13
to adt...@googlegroups.com
Android Studio 0.2.3
Build Tools 18.0.1
Gradle 0.5.x

When I put one of my custom views in a layout, the layout editor in Android Studio throws an exception, a android.content.res.Resources$NotFoundException.

The offending Java code line is just obtaining an existing resource from my project/module (I checked whether the resource is really there), but the preview of the XML rendering in Android Studio somehow can't find it.
(BTW: resources from android.R are found without problem)

Is this a known issue?

Streets Of Boston

unread,
Aug 5, 2013, 5:48:06 PM8/5/13
to adt...@googlegroups.com
Note that these exceptions are thrown by code in the custom views' constructors (.e.g getContext().getResources().getDrawable(....) ).
These exceptions are not thrown if the resources are specified in the XML through attributes in the "android:" namespace.

Streets Of Boston

unread,
Aug 8, 2013, 9:02:59 AM8/8/13
to adt...@googlegroups.com
Small bump....;-)

Xavier Ducrohet

unread,
Aug 8, 2013, 1:02:48 PM8/8/13
to adt...@googlegroups.com
Tor was doing some work on the resources support in the layout editor but then went on vacations. He just got back so I'm sure he'll look into this soon.


Small bump....;-)
--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

Streets Of Boston

unread,
Aug 8, 2013, 2:07:03 PM8/8/13
to adt...@googlegroups.com
Thanks for the update! I'll look for his reply when he's ready and back at work :)

Tor Norbye

unread,
Aug 9, 2013, 1:25:48 PM8/9/13
to adt...@googlegroups.com
I'm working on this stuff now; it's tracked in issues https://code.google.com/p/android/issues/detail?id=55626 and https://code.google.com/p/android/issues/detail?id=57676 (may in fact be same issue). 

-- Tor

Streets Of Boston

unread,
Aug 9, 2013, 2:04:25 PM8/9/13
to adt...@googlegroups.com
Thank you, Tor!


It works fine if all the resources are part of android.R (i.e. the system's resources).
It works fine in custom and non-custom views when they use my own style and theme definitions that include my own custom resources.

It does not work when my own resources are called/referenced from Java code in a custom view, and this exception is thrown, even after rebuilding the code. 

Chase Turner

unread,
Jan 3, 2014, 3:06:10 PM1/3/14
to adt...@googlegroups.com
Bumping for hope that Tor looks into this issue.


On Monday, August 5, 2013 11:54:04 AM UTC-4, Streets Of Boston wrote:

Tor Norbye

unread,
Jan 6, 2014, 10:59:42 AM1/6/14
to adt...@googlegroups.com
On Fri, Jan 3, 2014 at 12:06 PM, Chase Turner <chase....@i-cubed.com> wrote:
Bumping for hope that Tor looks into this issue.

As far as I know those bugs were fixed in August/September. If you're seeing something similar, can you give more details on what it is you're seeing (and which version you're using). Filing a bug would be even better such that it doesn't get lost.

-- Tor

Reply all
Reply to author
Forward
0 new messages