No virtual method getCamera() - Xamarin.AndroidX.Camera

VPrasanth 51 Reputation points
2021-12-02T16:38:14.98+00:00

Hi,

I need help in solving this issue.

I was using the CameraX sample from https://github.com/venetasoft/Xamarin.CameraX., and this repo is using older Xamarin.AndroidX.Camera.Core and other dependencies.

I had updated all AndroidX.Camera packages to the latest versions(1.0.2.1), and getting the below error.
I need to set the custom ISO, custom exposure and white balance.
There is no option of setting the exposure etc in the older versions of the AndroidX.Camera packages, so I endedup in upgrading the packages.

Since then, am getting the below issue and no clue to fix this exception:

[MonoDroid] java.lang.NoSuchMethodError: No virtual method getCamera()Landroidx/camera/core/Camera; in class Landroidx/camera/core/SurfaceRequest; or its super classes (declaration of 'androidx.camera.core.SurfaceRequest' appears in /data/app/~~x4sngehli4tT62zv5UDu1g==/com.companyname.camerax-tb0zodG0-w9uEdnnsbO9AA==/base.apk)
[MonoDroid] at androidx.camera.view.PreviewView.lambda$createSurfaceProvider$1$PreviewView(PreviewView.java:205)
[MonoDroid] at androidx.camera.view.-$$Lambda$PreviewView$n1PRP3s6fDboGjmt9Yty7nYrFM0.onSurfaceRequested(Unknown Source:2)
[MonoDroid] at androidx.camera.core.Preview.lambda$sendSurfaceRequestIfReady$1(Preview.java:390)
[MonoDroid] at androidx.camera.core.-$$Lambda$Preview$cQQSNpTD_vzDR540rq5dmfARJz4.run(Unknown Source:4)
[MonoDroid] at android.os.Handler.handleCallback(Handler.java:938)
[MonoDroid] at android.os.Handler.dispatchMessage(Handler.java:99)
[MonoDroid] at android.os.Looper.loop(Looper.java:246)
[MonoDroid] at android.app.ActivityThread.main(ActivityThread.java:8633)
[MonoDroid] at java.lang.reflect.Method.invoke(Native Method)
[MonoDroid] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
[MonoDroid] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Any idea of how to solve this?

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,261 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 64,571 Reputation points Microsoft Vendor
    2021-12-03T04:30:31.157+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    I try to download this simple, then I update all AndroidX.Camera packages to the latest versions(1.0.2.1), And I run it in my android 9.0 and android 11 emulator, both of them are running normally without this exception. You can download my simple from this thread:

    https://github.com/microsoft/CSSClientAppsXamarinSampleCode/tree/main/Xamarin.CameraX1

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful