This is a simple problem, but I'm having problems with it...
I'm trying to use Google common collection's Objects.equal()
method in a GWT client code, but I'm keep getting the error
20:12:10.001 [ERROR] [gwt_regex] Line 39: No source code is available for type com.google.common.base.Objects; did you forget to inherit a required module?
Tried to Google for the answer, but couldn't find any answer regarding this - everyone just said "Google collection should work off the box with GWT".开发者_如何学JAVA
You need to inherit the module file:
<inherits name='com.google.common.Collect.gwt.xml' />
and add the source files of both collections and additional gwt specific files. The first are in the zip file from the project page, the latter are available in the gwt folder in collections project trunk: http://code.google.com/p/google-collections/source/browse/#svn/trunk/gwt
To solve your error (No source code is available for type com.google.common.base.Objects), you just need to include Base GWT module :
<inherits name="com.google.common.base.Base" />
If you want to use classes related to collections, you need to include Collect GWT module :
<inherits name="com.google.common.collect.Collect" />
PS : tested with GUAVA GWT 17.0
Hilbrand's answer didn't quite work (it gave me bunch of errors when Google collection classes were loaded), and I found another solution.
- Check out google collection - http://google-collections.googlecode.com/svn/trunk/
- Run the ant target "jargwt"
- Add the built jar file "google-collect-gwt-snapshot.jar" to your application's classpath.
- Add in your GWT application's module.
The reason Hilbrand's solution didn't work was because Google collection contains alot of gwt-incompaitable java files, and the Collect.gwt.xml module file selects ALL java file under Google Collection.
i had the same issue, below steps solved my problem.
i found the "guava-15.0.jar" in the build path then i added one more "guava-gwt-15.0.jar" file to build path
精彩评论