我正在尝试使用Google Play Services (Vision)中的新功能将QR代码扫描添加到我的应用程序中。但是当我运行我的应用程序时,我得到了这样的信息:
I/Vision﹕ Supported ABIS: [armeabi-v7a, armeabi]
D/Vision﹕ Library not found: /data/data/com.google.android.gms/files/com.google.android.gms.vision/barcode/libs/armeabi-v7a/libbarhopper.so
I/Vision﹕ Requesting barcode detector download.
我已经按照教程声明了条形码依赖性:
<meta-data
android:name="com.google.android.gms.vision.DEPENDENCIES"
android:value="barcode" />
我试着重新安装应用程序,重新启动手机,没有任何帮助。
使用Google 7.8,设备上安装的版本为7.8.11。
compile 'com.google.android.gms:play-services-vision:7.8.0'
用于创建条形码检测器的代码:
boolean initBarcodeDetector() {
final BarcodeTrackerFactory barcodeTrackerFactory = new BarcodeTrackerFactory(this);
final MultiProcessor<Barcode> multiProcessor = new MultiProcessor.Builder<>(barcodeTrackerFactory)
.build();
barcodeDetector = new BarcodeDetector.Builder(this)
.build();
barcodeDetector.setProcessor(multiProcessor);
if (barcodeDetector.isOperational() == false) {
Toast.makeText(this, R.string.barcode_not_operational, Toast.LENGTH_LONG).show();
finish();
return false;
}
return true;
}
上面的关闭返回false并完成活动,因为barcodeDetector.isOperational()
返回false
。
发布于 2015-08-20 08:49:30
在我清除缓存并释放一些空间之后,它就开始工作了。我有“仅”400 no的空闲空间,并且没有错误消息表明这一点。
发布于 2016-05-22 05:13:27
谷歌已经确认了一个很快就会修复的漏洞,这在某些情况下会阻止你使用这个条形码/人脸检测库(链接here):
它也写在谷歌的github样本回购报告的一些问题上:
https://github.com/googlesamples/android-vision/issues
示例(here):
今天刚刚发布的GMSCore (v9)新版本有一个已知的问题。
发布于 2015-08-19 08:26:39
基于以下文档的: https://developers.google.com/android/reference/com/google/android/gms/vision/package-summary 和 https://developers.google.com/android/reference/com/google/android/gms/vision/Detector#isOperational()
文档:
公共布尔值isOperational() 指示检测器是否具有所有本地可用的所需依赖项,以便进行检测。 当应用程序首次安装时,可能需要下载所需的文件。如果返回false,则这些文件还不可用。通常这种下载是在应用程序安装时处理的,但这并不是保证的。在某些情况下,下载可能被延迟了。 如果您的代码添加了一个处理器,则还可以使用detectorIsOperational()方法指示检测器的操作状态。您可以在应用程序处理检测结果时检查此状态,并在适当情况下将此状态传递给用户。 如果检测器是可操作的,则返回·true,如果依赖项下载正在进行,则返回false
和
公共布尔值detectorIsOperational() 如果检测器是可操作的,则返回true,如果它不能工作,则返回false。在非操作情况下,检测器将不会返回任何结果。 当第一次启动应用程序时,如果需要下载以获得执行检测所需的相关库和模型文件,则检测器可在一段时间内不工作。
看起来你的设备需要完成通过Google服务下载库,这样你的应用程序才能马上工作。
基于Google示例(源中的评论):
// Note: The first time that an app using the barcode or face API is installed on a
// device, GMS will download a native libraries to the device in order to do detection.
// Usually this completes before the app is run for the first time. But if that
// download has not yet completed, then the above call will not detect any barcodes
// and/or faces.
//
// isOperational() can be used to check if the required native libraries are currently
// available. The detectors will automatically become operational once the library
// downloads complete on device.
https://stackoverflow.com/questions/32099530
复制相似问题