I am relatively new to developing on android and I am trying to implement a camera feature. I am using this page as a guide https://www.journaldev.com/30132/android-camerax-overview.
The section of code below is what I am having trouble with.
Rational aspectRatio = new Rational(textureView.getWidth(), textureView.getHeight());
Size screen = new Size(textureView.getWidth(), textureView.getHeight()); //size of the screen
PreviewConfig pConfig = new PreviewConfig.Builder().setTargetAspectRatio(aspectRatio).setTargetResolution(screen).build();
When a Rational is passed into setTargetAspectRatio, Android Studio gives the error 'Rational cannot be converted into AspectRatio.
According to the android developer page setTargetAspectRatio accepts the object AspectRatio, so I tried this:
AspectRatio aspectRatio = new AspectRatio(textureView.getWidth(), textureView.getHeight());
However I then get the error, on this line saying 'AspectRatio() has private access in androidx.camera.core.AspectRatio'. I am not sure what this error means as I have imported androidx.camera.core.AspectRatio normally.