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

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

为什么我不能在代码A中删除@SuppressLint("RestrictedApi")?限制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

android - 当我删除@SuppressLint(“RestrictedApi”)时,为什么Android Studio显示“仅从同一库组调用”?-LMLPHP

最佳答案

自从制作教程以来,库中发生了重大更改。
与本教程相同,将软件包版本恢复为1.0.0-alpha06可解决此问题。

10-08 03:17