gpt4 book ai didi

android - TestFairy 构建 apk 后初始化 fragment 上的 VerifyError

转载 作者:太空狗 更新时间:2023-10-29 14:09:15 26 4
gpt4 key购买 nike

这是一个奇怪的崩溃,任何人都可以解释它为什么会出现。

尝试在 ViewPager 中打开(通过标签或滑动)第三个 fragment 时出现崩溃(前两个此时自动初始化)Log中信息不多,直接提示'Verify'。

Android Studio创建的apk不能复现,只存在于TestFairy创建的apk中

STACK_TRACE=java.lang.VerifyError: .../CaseDetailUsersFragment
at ...CaseDetailViewPagerAdapter.getFragment(CaseDetailViewPagerAdapter.java:55)
at ...CaseDetailViewPagerAdapter.getItem(CaseDetailViewPagerAdapter.java:35)
at android.support.v13.app.FragmentPagerAdapter.instantiateItem(FragmentPagerAdapter.java:101)
at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:836)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1052)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:554)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:513)
at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:494)
at ...CaseDetailViewPagerFragment.onTabSelected(CaseDetailViewPagerFragment.java:148)
at
...view.MaterialTab.onTouch(MaterialTab.java:191)
at android.view.View.dispatchTouchEvent(View.java:7772)

CaseDetailViewPagerAdapter

public class CaseDetailViewPagerAdapter extends FragmentPagerAdapter{
/**
* class Adapter for Tabs in CaseDetail
*/
public class CaseDetailViewPagerAdapter extends FragmentPagerAdapter{
private final Context context;
private String caseId;
private int numItems;
public CaseDetailViewPagerAdapter(Context context, FragmentManager fm, String caseId, int numItems) {
super(fm);
this.context = context;
this.caseId = caseId;
this.numItems = numItems;
}

@Override
public Fragment getItem(int i) {
return getFragment(i);
}

@Override
public int getCount() {
return numItems;
}

/**
* @return instance of Fragment accordion to selected position
*/
private Fragment getFragment(int position) {
switch (position) {
case 0:
return CaseDetailLogFragment.newInstance(caseId);
case 1:
return CaseDetailChecklistFragment.newInstance(caseId);
case 2:
//55 line return CaseDetailUsersFragment.newInstance(caseId);
case 3:
return CaseDetailMapFragment.newInstance(caseId);
}
return null;
}
}

CaseDetailUsersFragment

public class CaseDetailUsersFragment extends Fragment {

public static final int USER_LOADER_ID = 3;
public static final int GROUP_LOADER_ID = 4;
static final String CASE_ID = "case_id";
String caseServerId;



public static CaseDetailUsersFragment newInstance(String caseId) {
CaseDetailUsersFragment usersFragment = new CaseDetailUsersFragment();
Bundle bundle = new Bundle();
bundle.putString(CASE_ID, caseId);
usersFragment.setArguments(bundle);
return usersFragment;
}

@Override
public void onServiceResult(long requestId, Intent requestIntent, int resultCode, Bundle resultData) {
super.onServiceResult(requestId, requestIntent, resultCode, resultData);
if (requestId == requestIdGetCaseUsersCommand && GetCaseUsersCommand.ACTION.equals(requestIntent.getAction())) {
requestIdGetCaseUsersCommand = BaseServiceHelper.DEFAULT_REQUEST_ID;
switch (resultCode) {
case Command.RESULT_SUCCESSFUL:
Logger.logD("onServiceResult finish refreshing");
Bundle b = new Bundle();
b.putString(CASE_ID, caseServerId);
getLoaderManager().restartLoader(USER_LOADER_ID, b, usersLoader);
showSwipeProgress(false);
break;
case Command.RESULT_FAILURE:
showSwipeProgress(false);
if (!NetworkHelper.isConnected(getActivity())) {
Toast.makeText(getActivity(), R.string.notification_error_no_connection, Toast.LENGTH_LONG).show();
} else if (resultData != null) {
ErrorInfo errorInfo = resultData.getParcelable(TransitionConstant.ERROR_INFO);
if (errorInfo != null) {
Toast.makeText(getActivity(), errorInfo.getErrorMessage(), Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getActivity(), getString(R.string.failure_get_case_list_error_code, resultData.getInt(TransitionConstant.STATUS_ERROR_CODE)), Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(getActivity(), R.string.failure_get_case_list, Toast.LENGTH_LONG).show();
}

break;
default:
break;
}
} else if (requestId == requestIdGetCaseGroupsCommand && GetCaseGroupsCommand.ACTION.equals(requestIntent.getAction())) {
requestIdGetCaseGroupsCommand = BaseServiceHelper.DEFAULT_REQUEST_ID;
switch (resultCode) {
case Command.RESULT_SUCCESSFUL:
Logger.logD("onServiceResult finish refreshing groups");
Bundle b = new Bundle();
b.putString(CASE_ID, caseServerId);
getLoaderManager().restartLoader(GROUP_LOADER_ID, b, groupLoader);
break;
case Command.RESULT_FAILURE:
if (!NetworkHelper.isConnected(getActivity())) {
Toast.makeText(getActivity(), R.string.notification_error_no_connection, Toast.LENGTH_LONG).show();
} else if (resultData != null) {
ErrorInfo errorInfo = resultData.getParcelable(TransitionConstant.ERROR_INFO);
if (errorInfo != null) {
Toast.makeText(getActivity(), errorInfo.getErrorMessage(), Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getActivity(), getString(R.string.failure_get_case_list_error_code, resultData.getInt(TransitionConstant.STATUS_ERROR_CODE)), Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(getActivity(), R.string.failure_get_case_list, Toast.LENGTH_LONG).show();
}

break;
default:
break;
}
}
}

compileSdkVersion 22
buildToolsVersion "22.0.1"
minSdkVersion 16
targetSdkVersion 22

已通过 break onServiceResult() 方法对两个方法进行修复。

在 TestFairy 日志中的警告中发现 W/dalvikvm? VFY: 拒绝 Lmy.package/MyClass;.methodV

最佳答案

这个错误的原因需要在应用程序logcat中dalwik的警告中找到例如:带 dalvikvm? VFY: 拒绝 Lmy.package/MyClass;.methodV

在这种情况下需要重构方法,因为你的方法太复杂了。在以下位置查看更详细的答案: VerifyError - Verifier rejected class

关于android - TestFairy 构建 apk 后初始化 fragment 上的 VerifyError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30344822/

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