0

I updated my Google Glass GDK from xe12 to xe16. My app was working perfectly well up until the update. Now when I run the app the glass throws:

java.lang.NoSuchMethodError: com.google.android.glass.app.Card.setText

I have followed the instructions posted in the discussions below:

[link 1] (NoSuchMethodError for Card.setText() in XE16)

[link 2] (Google Glass updated to KitKat, but new methods aren't showing up in Eclipse?)

However I still am not able to run my code.

I have made sure everything is up to date in Eclipse, my project's build target is the Glass Development Kit Preview (KitKat) and I have restarted Eclipse.

Any Suggestions?

here is the code for creating the Card:

import java.util.ArrayList;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;

import com.Y2014S.MirrorEdge.common_functions.CardScrollViewManager;
import com.google.android.glass.app.Card;
import com.google.android.glass.widget.CardScrollView;
public class MainActivity extends ActionBarActivity
{
private ArrayList<Card> mCards;
private CardScrollView mCardScrollView;
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    mCards = new ArrayList<Card>(10);
    mCards = createCard(mCards, this, "hello");
    CardScrollViewManager ScrollManager = new CardScrollViewManager(mCards);
    mCardScrollView = ScrollManager.createCardScrollView(mCardScrollView,
            getApplicationContext());
    setContentView(mCardScrollView);
}

public static ArrayList<Card> createCard(ArrayList<Card> mCards,
        final Context appContext, final String headerText)
{
    final Card newCard = new Card(appContext);
    CharSequence cs = headerText;
    newCard.setText(cs);
    mCards.add(newCard);
    return mCards;
}// end of createCard method

}

NOTE: I am adding the Card to the ArrayList in the method itself and returning the ArrayList to the Main Activity for later use.

Thanks!

Community
  • 1
  • 1

1 Answers1

0

You now need to use card.setText(CharSequence xx). By the way, String implements CharSequence. You may want to check out the release notes here.

You might try inheriting from Activity .. the following appears to do everything (no errors) .. (but the CardScrollViewManager stuff from your private source:

package com.example.stackglasstest;

import java.util.ArrayList;

import com.google.android.glass.app.Card;
import com.google.android.glass.widget.CardScrollView;

import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;



public class MainActivity extends Activity
{
private ArrayList<Card> mCards;
private CardScrollView mCardScrollView;
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    Context x = this;
    mCards = new ArrayList<Card>(10);
    mCards = createCard(mCards, this, "hello");
    CardScrollViewManager ScrollManager = new CardScrollViewManager(mCards);
    mCardScrollView = ScrollManager.createCardScrollView(mCardScrollView,
            getApplicationContext());
    setContentView(mCardScrollView);
}

public static ArrayList<Card> createCard(ArrayList<Card> mCards,
        final Context appContext, final String headerText)
{
    final Card newCard = new Card(appContext);
    CharSequence cs = headerText;
    newCard.setText(cs);
    mCards.add(newCard);
    return mCards;
}// end of createCard method

}

Here is the AndroidManifest ...

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.stackglasstest"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.stackglasstest.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
ErstwhileIII
  • 4,829
  • 2
  • 23
  • 37
  • I added the code as you suggested, still getting the same error. Have I missed something obvious? – user3608847 May 06 '14 at 17:24
  • made a new project and ran your code, got: "could not find method com.google.android.glass.app.Card.setText method referenced in com.example.test.MainActivity.createCard" – user3608847 May 06 '14 at 18:12
  • I am using the Glass Development preview (4.4.2) as the target build and have Glass Development Kit preview [Android 4.4.2] in the build path – user3608847 May 06 '14 at 18:16
  • So I completely reinstalled Eclipse (ADT) and I am still getting the same error as before, I am using the code from the answer above. The code I posted originally was working for about a month now consistently except after the update. I am thoroughly confused is there anything else I can try? – user3608847 May 07 '14 at 14:15
  • solution found: Glass was stating that it was up to date however after having a google guide check, that was not true. After legit update. Everything works correctly. – user3608847 May 07 '14 at 17:10
  • Glad you found the underlying problem! – ErstwhileIII May 07 '14 at 17:37