gpt4 book ai didi

android - 由于 'java.lang.IllegalAccessError',检测运行失败

转载 作者:IT老高 更新时间:2023-10-28 23:31:27 26 4
gpt4 key购买 nike

我现在正在为 Android 项目编写测试,只是不明白为什么这么痛苦!经过一整天的设置,我终于让它工作了,但是现在,在我编写了几个测试类之后,Intellij IDEA 支持:

Test failed to run to completion. Reason: 'Instrumentation run failed due to 'java.lang.IllegalAccessError''. Check device logcat for details
Test running failed: Instrumentation run failed due to 'java.lang.IllegalAccessError'

我几分钟前运行的测试无法再运行了。考虑到我回滚到最近的提交,一切都很理想,我没有更改任何设置,我只是想知道为什么。

这是 logcat 的意思:

02-12 20:16:09.398: E/AndroidRuntime(4922): FATAL EXCEPTION: main
02-12 20:16:09.398: E/AndroidRuntime(4922): java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
02-12 20:16:09.398: E/AndroidRuntime(4922): at com.actionbarsherlock.view.MenuInflater$MenuState.readItem(MenuInflater.java:327)
02-12 20:16:09.398: E/AndroidRuntime(4922): at com.actionbarsherlock.view.MenuInflater.parseMenu(MenuInflater.java:147)
02-12 20:16:09.398: E/AndroidRuntime(4922): at com.actionbarsherlock.view.MenuInflater.inflate(MenuInflater.java:97)
02-12 20:16:09.398: E/AndroidRuntime(4922): at <package>.ui.CheckPasswordActivity.onCreateOptionsMenu(CheckPasswordActivity.java:130)
02-12 20:16:09.398: E/AndroidRuntime(4922): at android.support.v4.app._ActionBarSherlockTrojanHorse.onCreatePanelMenu(_ActionBarSherlockTrojanHorse.java:45)
02-12 20:16:09.398: E/AndroidRuntime(4922): at com.actionbarsherlock.ActionBarSherlock.callbackCreateOptionsMenu(ActionBarSherlock.java:556)
02-12 20:16:09.398: E/AndroidRuntime(4922): at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchCreateOptionsMenu(ActionBarSherlockNative.java:60)
02-12 20:16:09.398: E/AndroidRuntime(4922): at com.actionbarsherlock.app.SherlockFragmentActivity.onCreatePanelMenu(SherlockFragmentActivity.java:154)
02-12 20:16:09.398: E/AndroidRuntime(4922): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:407)
02-12 20:16:09.398: E/AndroidRuntime(4922): at com.android.internal.policy.impl.PhoneWindow.doInvalidatePanelMenu(PhoneWindow.java:769)
02-12 20:16:09.398: E/AndroidRuntime(4922): at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:201)
02-12 20:16:09.398: E/AndroidRuntime(4922): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
02-12 20:16:09.398: E/AndroidRuntime(4922): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
02-12 20:16:09.398: E/AndroidRuntime(4922): at android.view.Choreographer.doFrame(Choreographer.java:531)
02-12 20:16:09.398: E/AndroidRuntime(4922): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
02-12 20:16:09.398: E/AndroidRuntime(4922): at android.os.Handler.handleCallback(Handler.java:725)
02-12 20:16:09.398: E/AndroidRuntime(4922): at android.os.Handler.dispatchMessage(Handler.java:92)
02-12 20:16:09.398: E/AndroidRuntime(4922): at android.os.Looper.loop(Looper.java:137)
02-12 20:16:09.398: E/AndroidRuntime(4922): at android.app.ActivityThread.main(ActivityThread.java:5039)
02-12 20:16:09.398: E/AndroidRuntime(4922): at java.lang.reflect.Method.invokeNative(Native Method)
02-12 20:16:09.398: E/AndroidRuntime(4922): at java.lang.reflect.Method.invoke(Method.java:511)
02-12 20:16:09.398: E/AndroidRuntime(4922): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-12 20:16:09.398: E/AndroidRuntime(4922): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-12 20:16:09.398: E/AndroidRuntime(4922): at dalvik.system.NativeStart.main(Native Method)

虽然我什至没有碰过这个类,但它所指的 CheckPasswordActivity line:130 只是:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.menu_check_password, menu);
return true;
}

最佳答案

我终于找到了解决办法。问题确实出在依赖项上,仍然不知道为什么它曾经工作然后突然被拒绝,但这是您的测试模块的依赖项应该是什么样的:

enter image description here

因此,总而言之,您需要确保为您的测试模块列出所有库和项目库,并标记为“已提供”,但 Robotium 库除外,即“编译”。

关于android - 由于 'java.lang.IllegalAccessError',检测运行失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14839162/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com