android - 为什么当我删除 @SuppressLint "only be called from with the same library group"时 Android Studio 会显示 ("RestrictedApi")?

标签 android android-studio

代码A来自CameraX项目,你可以看到source code .

当我删除 @SuppressLint("RestrictedApi") 时,Android Studio 将显示“只能从同一个库组中调用” ,您可以看到图 1。

为什么我不能删除 @SuppressLint("RestrictedApi")在代码 A 中? deos 限制 API 是什么意思?

代码 A

@SuppressLint("RestrictedApi")
    private fun updateCameraUi() {
        ...

        // Listener for button used to switch cameras
        controls.findViewById<ImageButton>(R.id.camera_switch_button).setOnClickListener {
            lensFacing = if (CameraX.LensFacing.FRONT == lensFacing) {
                CameraX.LensFacing.BACK
            } else {
                CameraX.LensFacing.FRONT
            }
            try {
                // Only bind use cases if we can query a camera with this orientation
                CameraX.getCameraWithLensFacing(lensFacing)

                // Unbind all use cases and bind them again with the new lens facing configuration
                CameraX.unbindAll()
                bindCameraUseCases()
            } catch (exc: Exception) {
                // Do nothing
            }
        }
    }

图片 1

enter image description here

最佳答案

自本教程制作以来,库中发生了重大变化。
将软件包版本恢复为 1.0.0-alpha06 ,和教程一样,解决了问题。

关于android - 为什么当我删除 @SuppressLint "only be called from with the same library group"时 Android Studio 会显示 ("RestrictedApi")?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58567716/

相关文章:

android - 如何强制停止应用程序

java - 仅在代码的特定位置检测nfc

android-studio - 如何逐行调试Android Studio项目(使用NDK和JNI)以查看工作流程?

android - ConstraintLayout 组与层

Android adb log - 在应用程序崩溃后收集最近的日志

java - Android 中的纪元时间与 PHP 不同

android - Android Studio 的 Eclipse 快捷方式

android-studio - 如何在更新到3.4.1时解决“发现了一些冲突”?

java - 安卓 Java : ArraylistMultiMap last value associated with the key is not getting deleted

java - 无法将外部 .jar 库导入 Eclipse 上的 Android 项目