Robolectric custom attribute error

518 views
Skip to first unread message

Kirill Mityakov

unread,
Mar 11, 2014, 6:05:35 AM3/11/14
to robol...@googlegroups.com
I'm getting the following inflation error, that looks like robolectric can't resolve string resource. I'd like to point that 'spb_default_speed' is custom attribute in SmoothProgressBar library.
Stacktrace is below:

android.view.InflateException: XML file c:\***\right_sliding_menu.xml line #-1 (sorry, not yet implemented): Error inflating class fr.castorflex.android.smoothprogressbar.SmoothProgressBar
	at android.view.LayoutInflater.createView(LayoutInflater.java:620)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
	at com.slidingmenu.lib.SlidingMenu.setSecondaryMenu(SlidingMenu.java:402)
**
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
**
Caused by: java.lang.RuntimeException: huh? ResName{com.example:string/spb_default_speed}
	at org.robolectric.shadows.Converter.convertAndFill(Converter.java:98)
	at org.robolectric.shadows.Converter.convertAndFill(Converter.java:50)
	at org.robolectric.shadows.ShadowResources.createTypedArray(ShadowResources.java:236)
	at org.robolectric.shadows.ShadowResources.attrsToTypedArray(ShadowResources.java:211)
	at org.robolectric.shadows.ShadowResources.access$000(ShadowResources.java:55)
	at org.robolectric.shadows.ShadowResources$ShadowTheme.obtainStyledAttributes(ShadowResources.java:478)
	at android.content.res.Resources$Theme.obtainStyledAttributes(Resources.java)


Kirill Mityakov

unread,
Mar 12, 2014, 4:42:23 AM3/12/14
to robol...@googlegroups.com
Looks like Robolectric can't parse such resources
<item name="spb_default_speed" format="float" type="string">1.0</item>

Mike Grafton

unread,
Mar 12, 2014, 10:13:53 AM3/12/14
to robol...@googlegroups.com
I believe this is issue #916. Please go onto github and add your +1 and hopefully this will get fixed soon.

Mike


On Wed, Mar 12, 2014 at 1:42 AM, Kirill Mityakov <kmi...@gmail.com> wrote:
Looks like Robolectric can't parse such resources
<item name="spb_default_speed" format="float" type="string">1.0</item>

--
You received this message because you are subscribed to the Google Groups "Robolectric" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robolectric...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kirill Mityakov

unread,
Mar 12, 2014, 10:53:34 AM3/12/14
to robol...@googlegroups.com
Thanks for answer, but looks like both #916 and #989 are closed and hasn't been fixed yet. :(

среда, 12 марта 2014 г., 18:13:53 UTC+4 пользователь Mike Grafton написал:

Kevin Bryant

unread,
Mar 14, 2014, 1:28:28 PM3/14/14
to robol...@googlegroups.com
Just as a note... issue #916 isn't actually closed. I believe the issue here is that the library has the type of that attribute set to "string" rather than "dimen". It seems to work for me when I set it to dimen, and the issue in #916 doesn't  occur for me after a project-clean with 2.3 snapshot.

Mike Grafton

unread,
Mar 14, 2014, 3:43:07 PM3/14/14
to robol...@googlegroups.com
You're right Kevin - this is not #916, sorry for the confusion. I'm not sure what's going on here. Kirill, are you trying against 2.3-SNAPSHOT?

Mike

Kirill Mityakov

unread,
Mar 16, 2014, 5:26:12 AM3/16/14
to robol...@googlegroups.com
Mike,

Yes, I tried with latest Robolectric (2.3-SNAPSHOT), and the problem dissapeared after I cloned the library and changed:

<item name="spb_default_speed" format="float" type="string">1.0</item>

to

<integer name="spb_default_speed">1</integer>

However, I faced with another crash that was caused by StackOverflowException (not able to paste full stacktrace right now). This is related to another library called ActionBar-PullToRefresh, that depends on SmoothProgressBar mentioned before. This time Robolectric wasn't able to eat the following code:

decorView.post(new Runnable() {
            @Override
            public void run() {
                if (decorView.getWindowToken() != null) {
                    // The Decor View has a Window Token, so we can add the HeaderView!
                    addHeaderViewToActivity(mHeaderView);
                } else {
                    // The Decor View doesn't have a Window Token yet, post ourselves again...
                    decorView.post(this);
                }
            }
        });

Looks like, this runable continuously posts itself, because getWindowToken() always returns null.

пятница, 14 марта 2014 г., 23:43:07 UTC+4 пользователь Mike Grafton написал:

Kirill Mityakov

unread,
Mar 20, 2014, 4:44:39 AM3/20/14
to robol...@googlegroups.com
Created another topic for this problem https://groups.google.com/forum/#!topic/robolectric/2zJ2t9CCjcI

воскресенье, 16 марта 2014 г., 13:26:12 UTC+4 пользователь Kirill Mityakov написал:

Jérémie Martinez

unread,
Mar 22, 2014, 5:41:59 AM3/22/14
to robol...@googlegroups.com
I had the same problem. I just submitted a PR to fix it. You can find it at https://github.com/robolectric/robolectric/pull/1009
Reply all
Reply to author
Forward
0 new messages