简体   繁体   English

Android - SDK 2.2上的java.lang.VerifyError

[英]Android - java.lang.VerifyError on SDK 2.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. 我让用户报告错误,以便我可以看到正在发生的堆栈跟踪,并且我得到了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. 根据我的阅读,这与外部库有关,或者在java.lang中的某些方法与目标Android SDK版本不兼容。

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. 用户使用的是Android 2.2.1,但该应用程序目前可以在许多其他2.2设备上运行,所以我试图找出从哪里开始挖掘。

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 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....

} }

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. 有一些设备在内部使用GSON,但是使库公开,当应用程序尝试引用其打包版本的gson时导致命名空间冲突。 A possible workaround is changing the namespace of the gson jar you have included using jarjar. 一种可能的解决方法是使用jarjar更改已包含的gson jar的命名空间。

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. 下面是该问题的一个主题 - 该主题包含至少一个遇到相同问题的开发人员提供的变通方法的描述。

there could be mismatch with the libs like Gson you have compiled and libs which are used in run time. 可能与您编译的Gson和运行时使用的库等lib不匹配。

Ref - Causes of getting a java.lang.VerifyError Ref - 获取java.lang.VerifyError的原因

It looks like ActionBar was released since API level 11 only, while android 2.2 is somewhat older (API level 8). 看起来ActionBar仅在API级别11发布,而Android 2.2稍微更旧(API级别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.. 我不知道视图是否被移植到2.2平台,但即使它是,你的用户仍然可以拥有旧的2.2版本..

Check that you are compiling against the correct Android SDK version. 检查您是否正在编译正确的Android SDK版本。 What is minSDK in your AndroidManifest.xml? AndroidManifest.xml中的minSDK是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM