MvvmCross / MvvmCross-AndroidSupport

Android support library packages for MvvmCross: The .NET MVVM framework for cross-platform solutions.
http://mvvmcross.com
15 stars 0 forks source link

Could not activate JNI Handle of java type MvxRecyclerView #252

Closed kenkosmowski closed 7 years ago

kenkosmowski commented 8 years ago

On using MvxRecyclerView, NotSupportedException occurs:

Steps to reproduce

  1. Use Android Support Library 23.3.0 and latest MvvmCross packages (4.1.6. / 4.1.7)
  2. Create View and add MvxRecyclerView

MyView.axml

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <RelativeLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
      <MvvmCross.Droid.Support.V7.RecyclerView.MvxRecyclerView
            android:id="@+id/RegistrationRegion_AddressSearchItems"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
  </RelativeLayout>
</ScrollView>
  1. Exception will be thrown at SetContentView()

    Expected behavior

should render MvxRecyclerView

Actual behavior

System.NotSupportedException Stacktrace:

05-27 15:57:04.509 W/monodroid( 7891): Could not activate JNI Handle 0xbfa744d8 (key_handle 0x22c6f168) of Java type 'mvvmcross/droid/support/v7/recyclerview/MvxRecyclerView' as managed type 'MvvmCross.Droid.Support.V7.RecyclerView.MvxRecyclerView'.
05-27 15:57:04.516 W/monodroid( 7891): Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
05-27 15:57:04.516 W/monodroid( 7891): Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.
05-27 15:57:04.516 W/monodroid( 7891):   --- End of managed exception stack trace ---
05-27 15:57:04.516 W/monodroid( 7891): java.lang.Error: Java callstack:
05-27 15:57:04.516 W/monodroid( 7891):  at mono.android.TypeManager.n_activate(Native Method)
05-27 15:57:04.516 W/monodroid( 7891):  at mono.android.TypeManager.Activate(TypeManager.java:7)
05-27 15:57:04.516 W/monodroid( 7891):  at mvvmcross.droid.support.v7.recyclerview.MvxRecyclerView.<init>(MvxRecyclerView.java:30)
05-27 15:57:04.516 W/monodroid( 7891):  at java.lang.reflect.Constructor.newInstance(Native Method)
05-27 15:57:04.516 W/monodroid( 7891):  at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
05-27 15:57:04.516 W/monodroid( 7891):  at android.view.LayoutInflater.createView(LayoutInflater.java:607)
05-27 15:57:04.516 W/monodroid( 7891):  at md5bf0126c95bf9fc0db24c02c9adb4cfa7.MvxLayoutInflater_PrivateFactoryWrapper2.n_onCreateView(Native Method)
05-27 15:57:04.516 W/monodroid( 7891):  at md5bf0126c95bf9fc0db24c02c9adb4cfa7.MvxLayoutInflater_PrivateFactoryWrapper2.onCreateView(MvxLayoutInflater_PrivateFactoryWrapper2.java:31)
05-27 15:57:04.516 W/monodroid( 7891):  at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:177)
05-27 15:57:04.516 W/monodroid( 7891):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:733)
05-27 15:57:04.516 W/monodroid( 7891):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
05-27 15:57:04.516 W/monodroid( 7891):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
05-27 15:57:04.516 W/monodroid( 7891):  at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
05-27 15:57:04.516 W/monodroid( 7891):  at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
05-27 15:57:04.516 W/monodroid( 7891):  at md562f2a8998733f8229b3a9079806fe29e.BaseActivity_1.n_onCreate(Native Method)
05-27 15:57:04.516 W/monodroid( 7891):  at md562f2a8998733f8229b3a9079806fe29e.BaseActivity_1.onCreate(BaseActivity_1.java:38)
05-27 15:57:04.516 W/monodroid( 7891):  at android.app.Activity.performCreate(Activity.java:5990)
05-27 15:57:04.516 W/monodroid( 7891):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
05-27 15:57:04.516 W/monodroid( 7891):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
05-27 15:57:04.516 W/monodroid( 7891):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
05-27 15:57:04.516 W/monodroid( 7891):  at android.app.ActivityThread.access$800(ActivityThread.java:151)
05-27 15:57:04.516 W/monodroid( 7891):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
05-27 15:57:04.516 W/monodroid( 7891):  at android.os.Handler.dispatchMessage(Handler.java:102)
05-27 15:57:04.516 W/monodroid( 7891):  at android.os.Looper.loop(Looper.java:135)
05-27 15:57:04.516 W/monodroid( 7891):  at android.app.ActivityThread.main(ActivityThread.java:5254)
05-27 15:57:04.516 W/monodroid( 7891):  at java.lang.reflect.Method.invoke(Native Method)
05-27 15:57:04.516 W/monodroid( 7891):  at java.lang.reflect.Method.invoke(Method.java:372)
05-27 15:57:04.516 W/monodroid( 7891):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
05-27 15:57:04.516 W/monodroid( 7891):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
kjeremy commented 8 years ago

Give us some code. There should be more to the stacktrace if you continue on.

kenkosmowski commented 8 years ago

added axml and stacktrace to original post

kjeremy commented 8 years ago

Might be a dup of #244 . Can you try the workaround in that bug?

tbalcom commented 8 years ago

The workaround suggested by @kjeremy worked for me. The workaround consists of adding Resources\values\attrs.xml file to your Droid project with the following content:

<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <declare-styleable name="MvxRecyclerView">
    <attr name="MvxItemTemplateSelector" format="string" />
  </declare-styleable>  
</resources>
kenkosmowski commented 8 years ago

Doesn't work for me. I get following error message during build:

Attribute "MvxItemTemplateSelector" has already been defined
kenkosmowski commented 8 years ago

Deleting bin & obj solved it. Workaround works for me now, too.

pMaske commented 8 years ago

Hello, I am getting this error on using one of our custom control. The error is only reproducible if I run the app in debug mode on Android 6.0.1, In release mode the custom control is rendered fine.

image