已知问题
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android 问题
- 对于捆绑的语言 ID,应用在升级到 AGP 7.0.0 或更高版本时可能会崩溃。
如需避免在
com.google.mlkit:language-id:16.1.1
或更低版本中发生崩溃,请添加以下规则:
-keep class com.google.mlkit.nl.languageid.internal.LanguageIdentificationJni { *; }
为避免 com.google.mlkit:language-id:17.0.0
或 com.google.mlkit:language-id:17.0.1
发生崩溃,请添加以下规则:
-keep class com.google.mlkit.nl.languageid.internal.ThickLanguageIdentifier { *; }
- 从
com.google.mlkit:face-detection:16.0.5
和 com.google.android.gms:play-services-mlkit-barcode-scanning:16.1.4
开始,使用非零 rotationDegrees 由 Bitmap 构建的 InputImage 会导致 FaceDetection API 出现“无效旋转”MlKitException。请使用较低版本,并等待我们发布包含此问题修复程序的下一版本。
在运行 camera-camera2:1.0.0-beta08 或更高版本的某些设备上,早于 com.google.mlkit:barcode-scanning:16.1.0
和 com.google.android.gms:play-services-mlkit-barcode-scanning:16.1.3
的 BarcodeScanning SDK 不起作用。您可以使用较低版本的 camera-camera2 来规避此问题。例如:
implementation "androidx.camera:camera-core:1.0.0-beta07"
implementation "androidx.camera:camera-camera2:1.0.0-beta07"
implementation "androidx.camera:camera-view:1.0.0-alpha14"
implementation "androidx.camera:camera-extensions:1.0.0-alpha14"
implementation "androidx.camera:camera-lifecycle:1.0.0-beta07"
在 com.google.mlkit:language-id:16.1.1
或更低版本中,原生方法可能会被自定义规则混淆。如果您遇到 java.lang.UnsatisfiedLinkError
等错误,请添加以下规则以保留它们:
-keepclasseswithmembernames class com.google.mlkit.nl.languageid.internal.LanguageIdentificationJni {
native <methods>;
}
对于文本识别、给图片加标签以及物体检测和跟踪 API,CameraX 和 Camera2 的性能仍不及 Camera1,因为从 CameraX 和 Camera2 对图片进行格式转换需要更多时间。
任务回调可能会在其注册的 activity 或 fragment 被销毁后执行。如果回调尝试访问在此期间已关闭的检测器,则可能会导致异常。如果您在 activity 中使用 ML Kit,可以注册一个activity 级监听器,该监听器会在 activity 停止时自动移除。如果您在 fragment 或其他环境中使用 ML Kit,则可以提供一个自定义执行器,以便在 fragment 被销毁时关闭执行。如需查看示例,请参阅 Vision 快速入门中的 ScopedExecutor.Java
。
对于使用位图以外图片格式的图片标注功能,捆绑变体比依赖于 Google Play 服务的“瘦”变体具有更好的性能。
对于数字手写 com.google.mlkit:digital-ink-recognition:17.0.0
或更低版本以及实体提取 com.google.mlkit:entity-extraction:16.0.0-beta2
或更低版本,如果您将 targetSdkVersion
设置为 31 并在 Android S 上运行,则会收到以下运行时异常。
Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE
or FLAG_MUTABLE
be specified when creating a PendingIntent
.
AndroidRuntime: Strongly consider using FLAG_IMMUTABLE
, only use FLAG_MUTABLE
if some functionality depends on the PendingIntent
being mutable, e.g. if it needs to be used with inline replies or bubbles.
此问题已在较新版本中得到修复。
如果您更喜欢使用旧版本,可以将 targetSdkVersion
设为小于 31,或者将以下代码添加到 build.gradle
中作为权宜解决方法。
// For apps targeting Android S+, add the following
constraints {
implementation 'androidx.work:work-runtime:2.7.0-alpha04'
}
iOS 问题
- 不支持基于 M1 的 Mac 上的模拟器。
- X86_64 模拟器不支持翻译
'GoogleMLKit/Translate', '4.0.0'
或更高版本,也不支持智能回复 'GoogleMLKit/SmartReply', '4.0.0'
或更高版本。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[[["\u003cp\u003eUpgrading to AGP 7.0.0+ with bundled Language ID may cause crashes, requiring specific keep rules to be added for different versions.\u003c/p\u003e\n"],["\u003cp\u003eInputImage created with Bitmap and rotationDegrees may cause errors with FaceDetection API in specific versions; use earlier versions or await a fix.\u003c/p\u003e\n"],["\u003cp\u003eBarcodeScanning SDKs before 16.1.0/16.1.3 have compatibility issues with camera-camera2:1.0.0-beta08+, consider using earlier camera-camera2 versions.\u003c/p\u003e\n"],["\u003cp\u003eTask callbacks may execute after Activity/Fragment destruction, potentially causing exceptions; use Activity-scoped listeners or custom executors for mitigation.\u003c/p\u003e\n"],["\u003cp\u003eOn Android S with targetSdkVersion 31, Digital Ink and Entity Extraction SDKs before specific versions may cause runtime exceptions regarding PendingIntent flags; upgrade to newer SDKs or apply a workaround.\u003c/p\u003e\n"]]],["Key actions and information regarding Android issues include: adding specific `-keep` rules to avoid crashes when using Language ID with AGP 7.0.0 or later; using earlier versions of Face Detection and Barcode Scanning due to \"invalid rotation\" and camera compatibility issues; adding a rule to fix `UnsatisfiedLinkError` with Language ID. Performance with CameraX/Camera2 is not optimized for Text Recognition, Image Labeling, and Object Detection. Activity-scoped listeners can be registered to prevent exceptions with Task callbacks. Setting `targetSdkVersion` or adding constraints to address Digital Ink and Entity Extraction issues.\n"],null,["Android issues\n\n- For bundled Language ID, the app may crash when upgrading to AGP 7.0.0 or later. To avoid the crash in `com.google.mlkit:language-id:16.1.1` or earlier, include the rule below: \n\n ```scdoc\n -keep class com.google.mlkit.nl.languageid.internal.LanguageIdentificationJni { *; }\n ```\n To avoid the crash in `com.google.mlkit:language-id:17.0.0` or `com.google.mlkit:language-id:17.0.1`, include the rule below: \n\n ```scdoc\n -keep class com.google.mlkit.nl.languageid.internal.ThickLanguageIdentifier { *; }\n ```\n- InputImage constructed by Bitmap with a non zero rotationDegrees causes an \"invalid rotation\" MlKitException for FaceDetection API since `com.google.mlkit:face-detection:16.0.5` and `com.google.android.gms:play-services-mlkit-barcode-scanning:16.1.4`. Please use an earlier version and wait for our next release which includes the fix for this issue.\n- BarcodeScanning SDKs pior to `com.google.mlkit:barcode-scanning:16.1.0`\n and `com.google.android.gms:play-services-mlkit-barcode-scanning:16.1.3`\n do not work on some devices running with camera-camera2:1.0.0-beta08 version or later.\n You can use an earlier version of camera-camera2 to bypass this issue. For example:\n\n ```carbon\n implementation \"androidx.camera:camera-core:1.0.0-beta07\"\n implementation \"androidx.camera:camera-camera2:1.0.0-beta07\"\n implementation \"androidx.camera:camera-view:1.0.0-alpha14\"\n implementation \"androidx.camera:camera-extensions:1.0.0-alpha14\"\n implementation \"androidx.camera:camera-lifecycle:1.0.0-beta07\"\n ```\n\n \u003cbr /\u003e\n\n- Native methods might be obfuscated by custom rules in `com.google.mlkit:language-id:16.1.1` or earlier.\n Include the following rule to keep them if you encounter errors like `java.lang.UnsatisfiedLinkError`:\n\n ```text\n -keepclasseswithmembernames class com.google.mlkit.nl.languageid.internal.LanguageIdentificationJni {\n native \u003cmethods\u003e;\n }\n ```\n\n \u003cbr /\u003e\n\n- For the Text Recognition, Image Labeling, and Object Detection and\n Tracking APIs, the performance with CameraX and Camera2 is still not on par\n with Camera1, because it takes more time to do format conversion for image\n from CameraX and Camera2.\n\n- [Task](https://developers.google.com/android/guides/tasks)\n callbacks might execute after the Activity or Fragment in which they have been\n registered has been destroyed. This might lead to an exception if the callback\n tries to access a detector that has been closed in the meantime. If you are\n using ML Kit in an Activity, you can register an\n [Activity-scoped listener](https://developers.google.com/android/guides/tasks#activity-scoped_listeners),\n which is automatically removed when the Activity is stopped. If you are\n using ML Kit in a Fragment or other environment, you can provide a custom\n executor that shuts down execution when the Fragment is destroyed. See\n `ScopedExecutor.Java` in the [Vision Quickstart](https://github.com/googlesamples/mlkit/tree/master/android/vision-quickstart) for an\n example.\n\n- For Image Labeling with image formats other than Bitmap, bundled variant\n has better performance than \"thin\" variant that depends on Google Play Services.\n\n- For Digital Ink `com.google.mlkit:digital-ink-recognition:17.0.0` or earlier\n and Entity Extraction `com.google.mlkit:entity-extraction:16.0.0-beta2` or earlier,\n you will get the following runtime exception if you set `targetSdkVersion` to 31\n and run on Android S.\n\n Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.\n AndroidRuntime: Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.\n\n This issue is fixed in our more recent releases.\n\n \u003cbr /\u003e\n\n If you prefer using older versions, you can either set `targetSdkVersion` to\n less than 31 or add the following to your `build.gradle` as a workaround. \n\n ```carbon\n // For apps targeting Android S+, add the following\n constraints {\n implementation 'androidx.work:work-runtime:2.7.0-alpha04'\n }\n ```\n\n \u003cbr /\u003e\n\niOS issues\n\n- Simulators on M1-based Mac are not supported.\n- X86_64 simulator is not supported for Translation `'GoogleMLKit/Translate', '4.0.0'` or later and Smart Reply `'GoogleMLKit/SmartReply', '4.0.0'` or later."]]