StartCalculatorActivity类的NoClassDefFoundError

时间:2019-01-15 14:04:26

标签: java android noclassdeffounderror google-glass

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

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

StartCalculatorActivity类为:

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文件添加到我的构建路径中。 预先感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

要运行需要google glass的应用程序,您首先必须在Android手机上下载glass,然后才能使用此类应用程序。

Checkout this link