StartCalculatorActivity 的 NoClassDefFoundError class

NoClassDefFoundError for StartCalculatorActivity class

我是 Android/Glass 开发的新手。我正在尝试制作一个语音控制的计算器。运行时崩溃的原因是:

java.lang.NoClassDefFoundError: 
Failed resolution of: Lcom/google/android/glass/widget/CardBuilder;

StartCalculatorActivity class 是:

public class StartCalculatorActivity extends Activity {


    private CardScrollView mCardScroller;
    CardBuilder card;
    private View mView;

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        card = new CardBuilder(this, CardBuilder.Layout.TEXT);
        mView = buildView();

        mCardScroller = new CardScrollView(this);
        mCardScroller.setAdapter(new CardScrollAdapter() {
            @Override
            public int getCount() {
                return 1;
            }

            @Override
            public Object getItem(int position) {
                return mView;
            }

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                return mView;
            }

            @Override
            public int getPosition(Object item) {
                if (mView.equals(item)) {
                    return 0;
                }
                return AdapterView.INVALID_POSITION;
            }
        });
        // Handle the TAP event.
        mCardScroller.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                // Plays disallowed sound to indicate that TAP actions are not supported.
                AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
                am.playSoundEffect(Sounds.DISALLOWED);
            }
        });
        setContentView(mCardScroller);
    }

    @Override
    protected void onResume() {
        super.onResume();
        mCardScroller.activate();
    }

    @Override
    protected void onPause() {
        mCardScroller.deactivate();
        super.onPause();
    }

    /**
     * Builds a Glass styled "Hello World!" view using the {@link CardBuilder} class.
     /*/
    private View buildView() {


        card.setText(R.string.hello_world);
        return card.getView();
    }

}

我通过创建一个新目录并将 JAR 复制粘贴到其中,将 JAR 文件添加到我的构建路径中。 预先感谢您的帮助。

对于需要 google glass 的 运行 应用程序,您首先必须在 android phone 上下载 glass,之后您就可以使用此类一个应用程序。

Checkout this link