I'm trying to compile the sample cameraxbasic but I get this error: Unresolved reference: WindowManager I checked gradle files and there is that dependency.
Asked
Active
Viewed 1,225 times
6
-
In particolar I get the error from CameraFragment.kt import androidx.window.WindowManager – Marco Piccirilli Apr 13 '22 at 18:19
-
I have exactly the same problem. Did you solve it? Help would be very much appreciated. – Cyrill Apr 15 '22 at 23:22
2 Answers
17
I reviewed the library change log at https://developer.android.com/jetpack/androidx/releases/window and adjusted the sample with following these changes to make it work. Hope this helps!
- use
implementation "androidx.window:window:1.1.0-alpha01"
- replace
WindowManager
withWindowInfoTracker
- replace
WindowManager(context)
withWindowInfoTracker.getOrCreate(view.context)
- replace
windowManager.getCurrentWindowMetrics().bounds
withWindowMetricsCalculator.getOrCreate().computeCurrentWindowMetrics(requireActivity()).bounds

AdamVe
- 3,236
- 2
- 18
- 13
0
funny how Microsoft has a guide on Window Manager
here:
https://learn.microsoft.com/en-us/dual-screen/android/jetpack/window-manager/?tabs=views
guide says which packages to include and how to use in the code, specifically to answer the question:
windowInfoTracker = WindowInfoTracker.getOrCreate(this@MainActivity)
while android has no official guide and a broken use case at the official github CameraX sample https://github.com/android/camera-samples/tree/master/CameraXBasic

Isaak Osipovich Dunayevsky
- 354
- 9
- 19