5

From the android market, I got the following crash report. Which I haven't found while testing my app. The crash occurs in PasswordActivity class. I am sending the stack trace and the code. Can anyone suggest to me where the crash occurs and why this occurs?

Stack Trace

java.lang.IncompatibleClassChangeError: interface not implemented
at in.plackal.lovecyclesfree.PasswordActivity.onCreate(PasswordActivity.java)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
at dalvik.system.NativeStart.main(Native Method)

My Code

public class PasswordActivity extends Activity implements Utilities { //Private Variables private EditText m_passwrdEditText;

private TextView m_passwrdErrorText;

private Resources m_res;

@Override
public void onCreate(Bundle savedInstanceState) {
    //Setup the activity
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);


    if (dm.widthPixels == 320 && dm.heightPixels == 480) {
        setContentView(R.layout.password_activity_hvga);
    } else {
        setContentView(R.layout.password_activity);
    }

    GoogleAnalyticsTracker tracker = GoogleAnalyticsTracker.getInstance();;
    tracker.startNewSession("UA-xxxxxxx-1", this);
    tracker.trackPageView("Password");
    tracker.dispatch();

    m_res = getResources();

    final Typeface face = Typeface.createFromAsset(getAssets(), "fonts/Cicle Semi.otf");

    m_passwrdErrorText = (TextView) findViewById(R.id.txt_error_message);
    m_passwrdErrorText.setTypeface(face);

    m_passwrdEditText = (EditText) findViewById(R.id.txt_edit_passwrd);
    m_passwrdEditText.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            m_passwrdEditText.setHint("");
            m_passwrdEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
            m_passwrdEditText.setTypeface(face);
        }
    });

    m_passwrdEditText.setTypeface(face);

    m_passwrdEditText.setOnKeyListener(new OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                String strPassEntered = m_passwrdEditText.getText().toString();
                String strPassSaved = CycleManager.getSingletonObject().getPassWord();
                m_passwrdEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                if (strPassSaved.equals(strPassEntered) || strPassEntered.equals(DEFAULT_PASSWORD)) {
                    Intent intent = new Intent(PasswordActivity.this, ActivityManager.class);
                    startActivity(intent);
                    PasswordActivity.this.finish();
                } else {
                    m_passwrdErrorText.setText(m_res.getString(R.string.passwrd_error_text));
                    m_passwrdEditText.setFocusable(true);
                }
            } else if (keyCode == KeyEvent.KEYCODE_DEL) {
                m_passwrdEditText.setHint(m_res.getString(R.string.passwrd_hint_text));
                m_passwrdErrorText.setText("");
            }

            m_passwrdEditText.setTypeface(face);
            return false;
        }
    });
}

}

AndroidDev
  • 4,521
  • 24
  • 78
  • 126

5 Answers5

1

I saw 2 reports on play store with IncompatibleClassChangeError: interface not implemented exception in Service class with log message containing onStartCommand(Unknown Source). I am using Eclipse to build the released application.

Fortunately, my roommate's phone encountered the same exception. After reading through the following link: What causes java.lang.IncompatibleClassChangeError?, the way I fixed it (at least on my roommate's phone) is by adding android-support-v4.jar to "libs" folder of the project and adding to build path. Then in the Project "Java Build Path" section under "Order and Export", exported the newly added jar file and removed selection for exporting "Android Private Libraries".

Community
  • 1
  • 1
kka
  • 11
  • 3
0

Investigate your interface, Utilities

public class PasswordActivity extends Activity implements Utilities

What functions do you need to implement to use this interface?

Eclipse often have quickfix for these issues

Daniel Magnusson
  • 9,541
  • 2
  • 38
  • 43
  • In my interface there are no function declared to be implemented. My utilities interface only contain final variables..so wherever i need this final variable i implemented this interface – AndroidDev May 29 '12 at 10:58
  • what happens if you remove the interface? – Daniel Magnusson May 29 '12 at 11:05
  • If i remove the interface then how can i used the variables that are declared in my utilities interface...Moreever the crash are found in android market..while testing i doesn't show any crash...one more crash i have found i.e java.lang.NullPointerException at android.widget.TextView.onTouchEvent is it becoz of using setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD) becoz it occurs in some devices only – AndroidDev May 29 '12 at 11:10
0

Must be some kind of installation glitch, reinstalling would probably help but there's no way you could tell that to the user, I'm afraid.

0

The method is quite long and the stack trace doesn't have a line number (did you delete it?)

One of the method calls in onCreate is through an interface which is not implemented on the device you got the error report from. This sounds weird at first.

The problem is that when you compiled the code it was using another version (probably newer) and that version has a class which implements an interface. That implements clause however was added between your target version (the one you compiled against) and the version which runs the device the report is coming from (older one). That .class file on the device doesn't have the implements for that interface, but your code is trying to call it. Here's an example:

// data is declared as T, and the class is generic with <T extends Closeable>
// ParcelFileDescriptor implements Closeable, but only above 4.1.1_r1
data.close();
this     //    3    7:aload_0         
.data    //    4    8:getfield        #18  <Field Closeable data>
.close() //    5   11:invokeinterface #19  <Method void Closeable.close()>
// so if you compiled the above on 4.4 and use it on 3.0 it should throw the same error
// when the data variable contains a ParcelFileDescriptor instance

You can try eliminating the possible lines:

Ignore the inner classes because the stack would be different for those, and ignore the constructors and primitive operations:

super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);     
getWindowManager().getDefaultDisplay().getMetrics(dm);
setContentView(R.layout.password_activity_hvga);
setContentView(R.layout.password_activity);

GoogleAnalyticsTracker tracker = GoogleAnalyticsTracker.getInstance();;
tracker.startNewSession("UA-xxxxxxx-1", this);
tracker.trackPageView("Password");
tracker.dispatch();

m_res = getResources();

final Typeface face = Typeface.createFromAsset(getAssets(), "fonts/Cicle Semi.otf");     

m_passwrdErrorText  = (TextView) findViewById(R.id.txt_error_message);
m_passwrdErrorText.setTypeface(face);
m_passwrdEditText  = (EditText) findViewById(R.id.txt_edit_passwrd);
m_passwrdEditText.setOnClickListener(...);
m_passwrdEditText.setTypeface(face);
m_passwrdEditText.setOnKeyListener(...);

From the remaining you could eliminate the this calls and the typed (TextView/EditText not interfaces) calls, that leaves:

getWindowManager().getDefaultDisplay().getMetrics(dm);

GoogleAnalyticsTracker tracker = GoogleAnalyticsTracker.getInstance();;
tracker.startNewSession("UA-xxxxxxx-1", this);
tracker.trackPageView("Password");
tracker.dispatch();

final Typeface face = Typeface.createFromAsset(getAssets(), "fonts/Cicle Semi.otf");     

BUT it could be one of the eliminated ones as well. The best way would be to reproduce on an emulator or real device having the same version as the reported device and see which line, but if that's not possible you could try to decompile the .class file and look for invokeinterface instructions in this method, that will narrow it down really well.

TWiStErRob
  • 44,762
  • 26
  • 170
  • 254
0

In my case it was:

class MyThread<T extends Closeable> extends Thread {
}

used as MyThread<DatagramSocket>: on Android API levels prior to 19 a DatagramSocket is not a Closeable. Read more.

Community
  • 1
  • 1
18446744073709551615
  • 16,368
  • 4
  • 94
  • 127