错误: 01-12 13:53:23.625 19314-19314 / com.example.lenovopc.xyz E / AndroidRuntime:FATAL EXCEPTION:main 处理:com.example.lenovopc.xyz,PID:19314 java.lang.RuntimeException:无法恢复活动 {com.example.lenovopc.xyz/com.example.lenovopc.xyz.ScanActivity}:android.view.InflateException:二进制XML文件行#0:二进制XML文件行#0:错误类com.scanlibrary.PolygonView错误 在 引起:java.lang.ClassNotFoundException:在路径上找不到类“com.scanlibrary.PolygonView”:DexPathList [[zip file“/data/app/com.example.lenovopc.xyz-2/base.apk”] ,nativeLibraryDirectories = [/ data / app / com.example.lenovopc.xyz-2 / lib / arm,/ system / lib,/ vendor / lib]]
代码: PickImageFragment.java
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d("", "onActivityResult" + resultCode);
Bitmap bitmap = null;
if (resultCode == Activity.RESULT_OK) {
try {
switch (requestCode) {
case ScanConstants.START_CAMERA_REQUEST_CODE:
bitmap = getBitmap(fileUri);
break;
case ScanConstants.PICKFILE_REQUEST_CODE:
bitmap = getBitmap(data.getData());
break;
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
getActivity().finish();
}
if (bitmap != null) {
postImagePick(bitmap);
}
}
protected void postImagePick(Bitmap bitmap) {
Uri uri = Utils.getUri(getActivity(), bitmap);
bitmap.recycle();
scanner.onBitmapSelect(uri);
}
private Bitmap getBitmap(Uri selectedimg) throws IOException {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 3;
AssetFileDescriptor fileDescriptor = null;
fileDescriptor =
getActivity().getContentResolver().openAssetFileDescriptor(selectedimg, "r");
Bitmap original
= BitmapFactory.decodeFileDescriptor(
fileDescriptor.getFileDescriptor(), null, options);
return original;
}
}
ScanActivity.java
public void onBitmapSelect(Uri uri) {
ScanFragment fragment = new ScanFragment();
Bundle bundle = new Bundle();
bundle.putParcelable(ScanConstants.SELECTED_BITMAP, uri);
fragment.setArguments(bundle);
android.app.FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.add(R.id.content, fragment);
fragmentTransaction.addToBackStack(ScanFragment.class.toString());
fragmentTransaction.commit();
}
ScanFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
***view = inflater.inflate(R.layout.scan_fragment_layout, null);***
init();
return view;
}