1

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.

Navidk
  • 612
  • 6
  • 14
  • that error is saying that the program can't find the jar during RUNTIME. So, check your runtime classpath – aran Jan 15 '19 at 14:06
  • Please have a look here: https://stackoverflow.com/questions/26060105/google-glass-returning-noclassdeffounderror-for-glass-widget-cardbuilder – YingYang Jan 15 '19 at 14:07
  • I had a look at that question, however I am not using "Card", instead using "CardBuilder" already. @YingYang – Navidk Jan 15 '19 at 14:11
  • I went to project->right-clicked on app->clicked on Open Module Settings->Dependencies. The library I had added was present there with Scope " Compile". @AsierAranbarri – Navidk Jan 15 '19 at 14:14

1 Answers1

1

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

sfk
  • 50
  • 5