javaandroidnoclassdeffounderrorgoogle-glass

NoClassDefFoundError for StartCalculatorActivity class


I'm new to Android/Glass development. I am trying to make a calculator which is voice controlled. The runtime crash occurs due to this:

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

The StartCalculatorActivity class is :

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();
    }

}

I added JAR files to my buildpath by making a new directory and copy -pasting the JARs into it. Thanks in advance for your help.


Solution

  • To run an application which requires google glass, you will first have to download glass on your android phone after which you will be able to use such an app.

    Checkout this link