Xamarin MvvmCross java.lang.ClassNotFoundException: Didn't find class "Mvx.MvxImageView"

DavidDolanDavidDolan IEMember
edited August 2015 in Xamarin.Android

Hi,

My app has started throwing exceptions stating it can't find the Mvx.MvxImageView class. It throws on BindingInflate within the OnCreateView of a MvxFragment. The fragment is for an image in a gallery. The trace and XML is below.

Any ideas why it can't find Mvx.MvxImageView?

XML

<?xml version="1.0" encoding="utf-8"?>

<Mvx.MvxImageView
class="cirrious.mvvmcross.binding.droid.views.MvxImageView"
android:src="@android:drawable/ic_menu_gallery"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/imageView" />

Exception

08-17 16:28:17.040 E/AndroidRuntime(29309): FATAL EXCEPTION: main
08-17 16:28:17.040 E/AndroidRuntime(29309): Process: ie.myapp.android.app, PID: 29309
08-17 16:28:17.040 E/AndroidRuntime(29309): android.view.InflateException: Binary XML file line #1: Error inflating class Mvx.MvxImageView
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
08-17 16:28:17.040 E/AndroidRuntime(29309): at myapp.mobile.droid.views.fragments.GalleryImageFragment.n_onCreateView(Native Method)
08-17 16:28:17.040 E/AndroidRuntime(29309): at myapp.mobile.droid.views.fragments.GalleryImageFragment.onCreateView(GalleryImageFragment.java:28)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:490)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.support.v4.view.ViewPager.populate(ViewPager.java:1105)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.support.v4.view.ViewPager.populate(ViewPager.java:951)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1473)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.View.measure(View.java:17430)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.View.measure(View.java:17430)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.View.measure(View.java:17430)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
08-17 16:28:17.040 E/AndroidRuntime(29309): at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:447)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.View.measure(View.java:17430)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
08-17 16:28:17.040 E/AndroidRuntime(29309): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2560)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.View.measure(View.java:17430)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2001)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1166)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1372)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.Choreographer.doCallbacks(Choreographer.java:580)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.Choreographer.doFrame(Choreographer.java:550)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.os.Handler.handleCallback(Handler.java:739)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.os.Handler.dispatchMessage(Handler.java:95)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.os.Looper.loop(Looper.java:135)
08-17 16:28:17.040 E/AndroidRuntime(29309): at android.app.ActivityThread.main(ActivityThread.java:5221)
08-17 16:28:17.040 E/AndroidRuntime(29309): at java.lang.reflect.Method.invoke(Native Method)
08-17 16:28:17.040 E/AndroidRuntime(29309): at java.lang.reflect.Method.invoke(Method.java:372)
08-17 16:28:17.040 E/AndroidRuntime(29309): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
08-17 16:28:17.040 E/AndroidRuntime(29309): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
08-17 16:28:17.040 E/AndroidRuntime(29309): Caused by: java.lang.ClassNotFoundException: Didn't find class "Mvx.MvxImageView" on path: DexPathList[[zip file "/data/app/ie.myapp.android.app-1/base.apk"],nativeLibraryDirectories=[/data/app/ie.myapp.android.app-1/lib/x86, /vendor/lib, /system/lib]]
08-17 16:28:17.040 E/AndroidRuntime(29309): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
08-17 16:28:17.040 E/AndroidRuntime(29309): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-17 16:28:17.040 E/AndroidRuntime(29309): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
08-17 16:28:17.040 E/AndroidRuntime(29309): at androi
08-17 16:28:20.605 I/Process (29309): Sending signal. PID: 29309 SIG: 9

Posts

  • JeremyKolbJeremyKolb USMember ✭✭✭

    Use this instead:

    <MvxImageView
    android:src="@android:drawable/ic_menu_gallery"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/imageView" />
    
  • DavidDolanDavidDolan IEMember

    Hi Jeremy. Still can't find class exception changes to;

    java.lang.ClassNotFoundException: Didn't find class "android.view.MvxImageView"

  • Martijn00Martijn00 NLInsider, University ✭✭✭

    Which version of MvvmCross are you running?

  • DavidDolanDavidDolan IEMember

    Cirrious.MvvmCross.Droid has a version of 1.0.0.0

    I've fixed this by creating my own CustomImageView, inheriting from MvxImageView, adding the following constructor:

            public CustomImageView(IntPtr handle, JniHandleOwnership transfer)
                : base(handle, transfer)
            { }
    

    Then changing my XML to

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@color/white">
        <myapp.mobile.droid.views.CustomImageView
            android:src="@drawable/icon"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/imageView"
            android:background="@color/white" />
    </LinearLayout>
    
  • Martijn00Martijn00 NLInsider, University ✭✭✭

    1.0.0.0 is the version of the dll not the version of the MvvmCross package. It should be something like 3.5.2 or 4.0.0-beta2.

    I don't see why you need to add that custom imageview, see: https://github.com/MvvmCross/MvvmCross/blob/491eb201423b0b4a872e31e05500554a1a149992/Cirrious/Cirrious.MvvmCross.Binding.Droid/Views/MvxImageView.cs#L113

    You might just need to update to 4.0.0-beta2 which fixes some stuff on views like this.

  • DavidDolanDavidDolan IEMember

    I'm not going to update to a beta. The whole thing is unstable enough for me at the moment.

    The ctor was not being found, the exception I was getting stated that the constructor wasn't on the class. Once I add my own custom image viewer and added the constructor, it worked.

    This commit on Jul 13th added the ctor to MvxImageView.

    https://github.com/MvvmCross/MvvmCross/commit/e51168de9de6341eae4eb8d705442d940a395389

    It's version 3.5.

    Thanks

  • Martijn00Martijn00 NLInsider, University ✭✭✭

    There are some huge improvements in 4.0 which one of is: https://github.com/MvvmCross/MvvmCross/pull/1064

    So i think this has nothing to do with the ctor, but rather the xaml where you add the control.

  • DavidDolanDavidDolan IEMember

    I'm not sure how an addition to version 4 helps my problem using 3.5. I tried using the full namespace.

    The exception stated that the ctor was missing, once I added it, it worked.

    Of course, others should just update to 4.0, where the ctor is added, but that's not worth it for us as the app won't be in use for much longer.

    Thanks for your help.

  • Hi Martin,

    I am newbie in Xamarin, and have the same issue, I wants to show the images in my MvxRecyclerview from URLs, I have checked the documentation and the MvxImageView is removed on mvvmCross 6.0 onwards and there's no proper documentations how to load the image in listview from urls.

  • ZuluZulu COMember ✭✭

    I have the same problem, when I was usign MVVM Cross 5.1.1 it works, but when I use the version 6.2.2 I got this error:

    Java.Lang.ClassNotFoundException: Didn't find class "android.view.MvxImageView" on path: DexPathList[[zip file "/data/app/MVVMCross6.Droid.MVVMCross6.Droid-1/base.apk"],nativeLibraryDirectories=[/data/app/MVVMCross6.Droid.MVVMCross6.Droid-1/lib/arm, /data/app/MVVMCross6.Droid.MVVMCross6.Droid-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]

    My layout is:

    Someone have any idea?

  • ZuluZulu COMember ✭✭

    The layout is:

    <MvxImageView
        android:layout_width="75dp"
        android:layout_height="75dp"
        android:layout_margin="10dp"
        local:MvxBind="ImageUrl ImageUrl" />
    
Sign In or Register to comment.