gpt4 book ai didi

android - Google Play 服务在 Android 2.3 Vision API 上崩溃

转载 作者:行者123 更新时间:2023-11-29 00:07:55 24 4
gpt4 key购买 nike

我将 Android Vision API 用于 QR 码扫描器,它在除 Android 2.3.x 设备外的多个 Android 设备和版本上运行良好。当我打开二维码扫描器时,会显示一个对话框,显示 google-play-services 崩溃。在 Logcat 中,我看到以下错误。

FATAL EXCEPTION: AsyncOperationService[VisionDependencyIntentService]
java.lang.NoSuchMethodError: android.content.SharedPreferences.getStringSet
at com.google.android.gms.vision.service.VisionDependencyIntentService.b(SourceFile:185)
at com.google.android.gms.vision.service.VisionDependencyIntentService.a(SourceFile:174)
at com.google.android.gms.vision.service.a.a.a(SourceFile:45)
at com.google.android.gms.chimera.f.run(SourceFile:179)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
at java.lang.Thread.run(Thread.java:1019)

这是我的 fragment 代码

@Override
public void onViewCreated(View view, Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);

Activity activity = getActivity();

preview = (CameraSourcePreview) view.findViewById(R.id.preview);

int connectionResult = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(activity);
if (connectionResult == ConnectionResult.SUCCESS)
{
// create a barcode detector.
BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(activity).setBarcodeFormats(Barcode.QR_CODE)
.build();

// create a processor to filter qr-codes and a tracker to handle the selected qr-code.
barcodeDetector.setProcessor(new QrCodeProcessor(barcodeDetector, new QrCodeTracker(this)));

if (barcodeDetector.isOperational())
{
// Creates and starts the camera.
cameraSource = new CameraSource.Builder(activity, barcodeDetector)
.setFacing(CameraSource.CAMERA_FACING_BACK).setRequestedPreviewSize(1600, 1024)
.setRequestedFps(15.0f).build();
}
else
{
showAlert(R.string.QrCodeScanner_alert_play_services_not_operational_header,
R.string.QrCodeScanner_alert_play_services_not_operational_body);
}
}
else
{
PlatformUtil.handlePlayServicesError(activity, connectionResult);
}
}

根据 Google Play 服务指南,应支持 Android 2.3: https://developers.google.com/android/guides/setup

我还尝试释放一些空间并按照以下建议恢复出厂设置:Google Vision barcode library not found没有任何成功。

有人知道我做错了什么吗?

最佳答案

看起来这个特定的 API 依赖于 SharedPreferences.getStringSet(),根据 Android docs , 仅在 API 11 (Android v3.0 Honeycomb) 中引入。

您将无法在 2.x 设备上使用它。

关于android - Google Play 服务在 Android 2.3 Vision API 上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32458351/

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