androidxamarinxamarin.androidgoogle-play-servicesandroid-vision

Java.Lang.ClassNotFoundException: Didn't find class "com.google.android.gms.vision.text.TextRecognizer$Builder" Xamarin Android


Getting Java.Lang.ClassNotFoundException error at the below line in Xamarin Android

TextRecognizer textRecognizer = new TextRecognizer.Builder(ApplicationContext).Build();

{Java.Lang.ClassNotFoundException: Didn't find class "com.google.android.gms.vision.text.TextRecognizer$Builder" on path: DexPathList[[zip file "/data/app/dine.dine-4Lcxwvl8j7kQmp8qGBPDCA==/base.apk"],nativeLibraryDirectories=[/data/app/dine.dine-4Lcxwvl8j7kQmp8qGBPDCA==/lib/x86, /data/app/dine.dine-4Lcxwvl8j7kQmp8qGBPDCA==/base.apk!/lib/x86, /system/lib]]
      at Java.Interop.JniEnvironment+Types.FindClass (System.String classname) [0x00114] in <286213b9e14c442ba8d8d94cc9dbec8e>:0 
      at Java.Interop.JniType..ctor (System.String classname) [0x00006] in <286213b9e14c442ba8d8d94cc9dbec8e>:0 
      at Java.Interop.JniType.GetCachedJniType (Java.Interop.JniType& cachedType, System.String classname) [0x00018] in <286213b9e14c442ba8d8d94cc9dbec8e>:0 
      at Java.Interop.JniPeerMembers.get_JniPeerType () [0x0000c] in <286213b9e14c442ba8d8d94cc9dbec8e>:0 
      at Java.Interop.JniPeerMembers+JniInstanceMethods.get_JniPeerType () [0x0000a] in <286213b9e14c442ba8d8d94cc9dbec8e>:0 
      at Java.Interop.JniPeerMembers+JniInstanceMethods.StartCreateInstance (System.String constructorSignature, System.Type declaringType, Java.Interop.JniArgumentValue* parameters) [0x0003f] in <286213b9e14c442ba8d8d94cc9dbec8e>:0 
      at Android.Gms.Vision.Texts.TextRecognizer+Builder..ctor (Android.Content.Context context) [0x0005b] in <3d29e02cc4534fbf8547810969e46514>:0 
      at dine.MainActivity.Ocr (Android.Graphics.Bitmap bitmap) [0x00001] in D:\dine\dine\MainActivity.cs:753 
      at dine.MainActivity.StartCapture () [0x001ad] in D:\dine\dine\MainActivity.cs:711 
      --- End of managed Java.Lang.ClassNotFoundException stack trace ---
    java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.vision.text.TextRecognizer$Builder" on path: DexPathList[[zip file "/data/app/dine.dine-4Lcxwvl8j7kQmp8qGBPDCA==/base.apk"],nativeLibraryDirectories=[/data/app/dine.dine-4Lcxwvl8j7kQmp8qGBPDCA==/lib/x86, /data/app/dine.dine-4Lcxwvl8j7kQmp8qGBPDCA==/base.apk!/lib/x86, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at mono.java.lang.RunnableImplementor.n_run(Native Method)
        at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
    }

Solution

  • Problem is i was using Preview version packages which is causing the problem, i changed the preview version packeges to stable version i.e Xamarin.GooglePlayServices.Vision 71.1502.0-preview1 to Xamarin.GooglePlayServices.Vision 60.1142.1, no more exceptions now.