问题
I'm very new to Glass development yet have run into a frustrating problem which has pretty well halted my progress entirely.
Upon building and running any Glass project, I am greeted with the error:
java.lang.NoClassDefFoundError: com.google.android.glass.widget.CardBuilder
This error occurs as soon as the CardBuilder
class is accessed. I have imported the class and no errors appear during building, it is when the code is actually ran on the device that the issue occurs.
Now interestingly, this error occurs even when using Google's own GDK example projects, not just projects I've coded myself. The only time it doesn't occur is when using the Stopwatch example project, I believe this to be because the Stopwatch doesn't implement the CardBuilder
class. I have tested it on multiple installs of Android Studio on both Linux, OS X, and Windows machines. At this point, I believe that perhaps there is a configuration problem on the Glass itself, or perhaps a very strange bug with the Android Studio.
Has anyone run into this problem before and successfully fixed it?
回答1:
The CardBuilder api is available after XE 21 and its corresponding GDK.
You need to update your GLASS and GDK or otherwise use the old Card api.
Google's GDK examples assume you have the new GDK and XE21.
Please see Google Glass GDK backward compatibility?.
Also, https://developers.google.com/glass/release-notes
XE21.0 - September 8, 2014
GDK
Replaced Card with CardBuilder, which supports many more layouts. Card is now deprecated and will be removed in a future release.
来源:https://stackoverflow.com/questions/26060105/google-glass-returning-noclassdeffounderror-for-glass-widget-cardbuilder