2

I recently launched my application to the Market and I've been in contact with a user who is reporting that when he launches my app, it display the Force Close/Report dialog. I asked the user to report the error so I could see the stack trace of what's happening and I'm getting the java.lang.VerifyError.

From what I've read, this has either something to do with an external library or an incompatibility in some method in java.lang with the targeted Android SDK version.

The user is on Android 2.2.1, but the app currently works on many other 2.2 devices, so I'm trying to figure out where to start digging.

Question: Does anybody have suggestions as to what would be the best thing to start looking into to find the issue? I can provide code or more information if needed, so please let me know.

Here's the Stack Trace:

java.lang.VerifyError: com.app.myapp.MainActivity
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1429)
at android.app.Instrumentation.newActivity(Instrumentation.java:1034)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2749)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2866)
at android.app.ActivityThread.access$2300(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2181)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:5097)
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:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)

Thanks in advance!

EDIT
Added per request of Konstantin

MainActivity.java

package com.app.myapp;

//Imports removed

public class MainActivity extends BaseActivity implements Runnable {

private LayoutInflater mInflater;
private SharedPreferences prefs;
private SharedPreferences.Editor prefsEditor;

    ....

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    loadActivity(savedInstanceState);
}

private void loadActivity(Bundle savedInstanceState) {
    setContentView(R.layout.mainlayout);

    ActionBar actionBar = (ActionBar)findViewById(R.id.actionbar);
    actionBar.setTitle("My App");
    actionBar.setHomeAction(new IntentAction(this, null, R.drawable.ic_actionbar_home));
    actionBar.addAction(new SearchAction(this, R.drawable.ic_actionbar_search));

    weatherThread = new Thread(this);
    try {
        ....Unrelated Code....

        //****HERE WAS THE PROBLEM****//
        Gson gson = new Gson();

        ....More Unrelated Code....
    } catch (JsonSyntaxException ex) { }

    initMembers();
    initControls();

    if (savedInstanceState != null) {
        mSelectedLayout = savedInstanceState.getInt("CURRENT_TAB");
        setCurrentTab();
    }
    else
        loadMainLayout();
}

    ....Other unrelated code....

}

hooked82
  • 6,336
  • 4
  • 41
  • 46
  • 1
    Show code from com.hookedroid.fishingcompanion.MainFish, otherwise it's hard to make assumptions. – Konstantin Burov Jul 30 '11 at 03:14
  • The code for that Activity is a little lengthy, is there anything in particular? I'll see if I can shorten it up for posting here – hooked82 Jul 30 '11 at 21:18
  • Post all field members and method signatures. Also onCreate method. – Konstantin Burov Jul 31 '11 at 10:25
  • @Konstantin - I've posted some code, let me know if this is what you were looking for. If not, I'll get whatever is needed to help. Thanks! – hooked82 Jul 31 '11 at 18:55
  • I've still not found a solution to this, does anybody have any clues as to why this might be happening? Or maybe a direction that I could look into. Thanks! – hooked82 Aug 03 '11 at 03:22
  • Your app says you've fixed the bug - can you post the Answer and mark it for others who may have a similar issue? – CrackerJack9 Aug 10 '11 at 16:49
  • Are you referring to my update to the app in the Market? If so, that was for a different FC issue and not this one. This is still an issue. – hooked82 Aug 10 '11 at 20:44

4 Answers4

9

There are a few devices which are using GSON internally, but made the library public, causing a namespace conflict when the application attempts to reference its packaged version of gson. A possible workaround is changing the namespace of the gson jar you have included using jarjar.

Heres a thread on the issue - The thread contains a description of at least one workaround supplied by another developer who encountered the same issue.

Alexander Lucas
  • 22,171
  • 3
  • 46
  • 43
  • That could very well be the issue as I see that bug exists on the HTC myTouch 4G with stock 2.2. This is the exact phone that the user has, so I'll compile a build for him and see if it resolves the issue. Thanks! – hooked82 Aug 13 '11 at 03:05
  • FYI, HTC is aware of this problem and will avoid it in the future! – Jesse Wilson May 15 '12 at 02:49
2

there could be mismatch with the libs like Gson you have compiled and libs which are used in run time.

Ref - Causes of getting a java.lang.VerifyError

Community
  • 1
  • 1
Riyaz Mohammed Ibrahim
  • 9,505
  • 5
  • 26
  • 33
  • If this were true, wouldn't it be the case for all devices and not just a single device? I've got 100+ users on a 2.2 device that aren't seeing this issue, but just one user that is seeing it on his 2.2 device. – hooked82 Aug 12 '11 at 17:59
1

It looks like ActionBar was released since API level 11 only, while android 2.2 is somewhat older (API level 8). So try it without the action bar. I do not know if the view was backported to 2.2 platform, but even if it was, your user can still have old 2.2 version..

Konstantin Burov
  • 68,980
  • 16
  • 115
  • 93
  • The ActionBar you see in the code is actually a custom implementation and not the one that comes in API level 11, so it is fully compatible all the way back to 1.6. – hooked82 Aug 01 '11 at 12:52
0

Check that you are compiling against the correct Android SDK version. What is minSDK in your AndroidManifest.xml?

CrackerJack9
  • 3,650
  • 1
  • 27
  • 48
  • I'm compiling against the correct SDK – hooked82 Aug 10 '11 at 20:47
  • No, I'm compiling against 8. I'm not using any classes or methods since 1.6, but will in future releases. I understand that if I do use any classes or methods only available after 1.6, that I need to gracefully handle them myself. – hooked82 Aug 10 '11 at 22:17
  • If you aren't using anything added after 1.6, compile against 1.6. That will be definitive. I read sometimes it throws VerifyError instead of NoSuchMethodException - so you may not be handling it after all. – CrackerJack9 Aug 10 '11 at 23:04
  • The user reporting this error is on 2.2 (8), which is the same version that I'm building against. – hooked82 Aug 11 '11 at 13:44