Robolectric freezing Eclipse. Saying lots of Dx warning: Ignoring InnerClasses attribute for an anonymous inner class

1,769 views
Skip to first unread message

Karussell

unread,
Jan 31, 2012, 5:32:02 PM1/31/12
to Robolectric
I know you guys are more IntelliJ fans (I'm more NetBeans ;)) but I
need to know how to setup robolectric on Eclipse. I can already
execute tests via right click->run configuration->maven test

But when I run as android application then eclipse throws a lot of
warnings [1] at me and then gets slightly slower and slower and
finally crashes. I could track it down that if I exclude the single
robolectric dependency from the pom (but still leave the maven
dependencies in the project) I can run it. What could be the reason?
Can it be a problem that I'm using the "older" android sdk 2.2.1 aka
"2.2_r3"? Or is it due to the fact that I'm using javac 1.6 specified
in the pom.xml?

I already tried to build robolectric myself but failed due to some
android classes missing [2] - which sounds logically to me since
android is only "provided" (?)

This is the same bug someone else already encountered but the provided
solutions don't work for me: http://stackoverflow.com/q/5591811/194609

Regards,
Peter.

[1]
[2012-01-31 23:27:08 - Project] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class (org.ibex.nestedvm.Runtime$1)
that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced
by a compiler that did not target the modern .class file format. The
recommended solution is to recompile the class from source, using an
up-to-date compiler and without specifying any "-target" type options.
The consequence of ignoring this warning is that reflective operations
on this class will incorrectly indicate that it is *not* an inner
class.
[2012-01-31 23:27:08 - Project] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class (org.ibex.nestedvm.Runtime
$TerminalFD$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced
by a compiler that did not target the modern .class file format. The
recommended solution is to recompile the class from source, using an
up-to-date compiler and without specifying any "-target" type options.
The consequence of ignoring this warning is that reflective operations
on this class will incorrectly indicate that it is *not* an inner
class.
[2012-01-31 23:27:08 - Project] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class (org.ibex.nestedvm.UnixRuntime
$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced
by a compiler that did not target the modern .class file format. The
recommended solution is to recompile the class from source, using an
up-to-date compiler and without specifying any "-target" type options.
The consequence of ignoring this warning is that reflective operations
on this class will incorrectly indicate that it is *not* an inner
class.
[2012-01-31 23:27:08 - Project] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class (org.ibex.nestedvm.UnixRuntime
$DevFS$1$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced
by a compiler that did not target the modern .class file format. The
recommended
solution is to recompile the class from source, using an up-to-date
compiler and without specifying any "-target" type options. The
consequence of ignoring
this warning is that reflective operations on this class will
incorrectly indicate that it is *not* an inner class.

[2]
....
TestWindow.java:[8,19] cannot find symbol
[ERROR] symbol : class InputQueue
[ERROR] location: package android.view
[ERROR] ../android/robolectric/src/main/java/com/xtremelabs/
robolectric/shadows/ShadowCamera.java:[28,38] cannot find symbol
[ERROR] symbol : class CameraInfo
[ERROR] location: class android.hardware.Camera
...

Karussell

unread,
Feb 1, 2012, 3:57:58 AM2/1/12
to Robolectric
Ok, removing the "maven enhancement" from the main project, then it
all works.

Then creating a separate Java-Test project as described** works now.

BTW: the description should be changed to

Step 1: "Import from existing maven project" OR "create a new Android
project"
Step 2: "Create Java project for tests"

Right?

Regards,
Peter.

**
http://pivotal.github.com/robolectric/eclipse-quick-start.html

Tyler Schultz

unread,
Feb 1, 2012, 5:36:56 PM2/1/12
to robol...@googlegroups.com
Thanks for the feedback.  If you think you have valid corrections for website, you can create a pull request.  The website is in the 'gh-pages' branch of the robolectric project.

Karussell

unread,
Feb 13, 2012, 10:17:08 AM2/13/12
to Robolectric
I think Dx warning thing is related to the fact that I was testing
directly within the main project via maven and robolectric which
generates 'wrong' class files. And when starting the project on the
device it confuses eclipse as it takes the class files from the same
folder I guess.

Peter.

Flo Klappan

unread,
Jan 10, 2013, 4:28:38 AM1/10/13
to robol...@googlegroups.com, tabley...@googlemail.com
What did you mean with "removing maven enhancement"? How exactly did you fix the problem and what's your setup now?

I have the same problem, using maven with eclipse ( m2e ) and robolectric in the main project.
I insist in using maven because otherwise i will break the whole build config. As i can see on some other threads its not supported to have an external maven project for testing. But the robolectric page says i should create a new project for testing. But how should i integrate the second project in my CI, if i can't use maven? Weird...

Testing with "Run as maven test" ( in eclipse! ) works fine and also using deployment to the phone. But thats time consuming. I still want to use my "run as android application" command. How can i achieve this?

Karussell

unread,
Jan 10, 2013, 4:43:01 AM1/10/13
to robol...@googlegroups.com, tabley...@googlemail.com
You can find this "maven enhancement" thing when you right click the main project - I had to create separate test project in eclipse.

In that test project you point to the test sources which can lay in the same folder like the main sources.

Also try NetBeans where everything (except on device debuging) worked for me at that time out of the box.

Peter.

Flo Klappan

unread,
Jan 10, 2013, 5:33:02 AM1/10/13
to robol...@googlegroups.com, tabley...@googlemail.com
Did you mean "disable maven nature"? Thats the only menu point i have in eclipse regarding maven if i right click the project.. Or do you mean in NetBeans?

Actually i can't move over to NetBeans because i'm glad to finally have a fully working development environment ;)

I will give the separated project a try though i have doubts because of the threads saying this wont work...

Thanks anyway for your help!

Flo

Karussell

unread,
Jan 10, 2013, 5:39:37 AM1/10/13
to robol...@googlegroups.com, tabley...@googlemail.com


Did you mean "disable maven nature"? Thats the only menu point i have in eclipse regarding maven if i right click the project.. Or do you mean in NetBeans?

yes probably that option ... and yes, in eclipse. 


Actually i can't move over to NetBeans because i'm glad to finally have a fully working development environment ;)

Just download netbeans and open that project ... really nothing more (no plugins, no project creation or config, no test setup, ...)

if the project builds on the command line, it will build in netbeans and you can just hit test etc.

 

I will give the separated project a try though i have doubts because of the threads saying this wont work...
 
again: a separate test project which is mavenized and a main project which isn't

But all that I'm writing without the project at hands ... so good luck :) !

Peter.

Flo Klappan

unread,
Jan 10, 2013, 6:58:25 AM1/10/13
to robol...@googlegroups.com, tabley...@googlemail.com
I will give it a try. thank you very much :)

Roberto Andrade

unread,
Apr 17, 2013, 4:13:34 PM4/17/13
to robol...@googlegroups.com, tabley...@googlemail.com
One other solution I've found to this is simply configuring the Eclipse project not to "export" Maven Dependencies as part of its build process.

You do that by right clicking the project and entering "Properties" > "Java Build Path" > "Order and Export" and from there just make sure the "Maven Dependencies" is not checked.

What the Android build system is trying to do is embed every single one of the JAR dependencies declared in your project (including Robolectric) - which it shouldn't do - as some of these things are only used for testing purposes and should not be baked into the APK as part of the Android build DEXing process.

Hope it helps,

Roberto
Reply all
Reply to author
Forward
Message has been deleted
0 new messages