Bug 17014 - Cheesebaron.HorizontalListView.Demo project crashes in release mode in Android 4.3 simu
Summary: Cheesebaron.HorizontalListView.Demo project crashes in release mode in Androi...
Status: RESOLVED NOT_ON_ROADMAP
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.10.1
Hardware: PC Windows
: High normal
Target Milestone: ---
Assignee: Alex Rønne Petersen
URL:
Depends on:
Blocks:
 
Reported: 2014-01-01 17:07 UTC by softlion
Modified: 2014-07-31 01:34 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_ON_ROADMAP

Description softlion 2014-01-01 17:07:57 UTC
You can find the demo project here: https://github.com/Cheesebaron/Cheesebaron.HorizontalListView

Do not use the demo project mvvmcross. Use the "simple" demo project. Switch to Release mode. Deploy and run on simulator or device. It will crash immediatly.

Also tested with 4.11.0 alpa and 4.10.2 beta.

My own project also crashes in release mode when using a class derived from AdapterView<BaseAdapter>, but on a different method call.

Both projects runs fine in debug mode, or in release mode with "Mono.Android" skipped from linking. Which is not an acceptable solution.
Comment 2 narayanp 2014-01-02 07:51:23 UTC
I have checked this issue with following build:

All Windows
X.S 4.2.2(build 2)
X.Android 4.10.1-73

I am also getting crash for attached application in release mode on Emulator 4.3(API18). This is the application Output for the same: https://gist.github.com/saurabh360/75893ba2f75fa4074825
Comment 3 Jonathan Pryor 2014-01-02 10:35:50 UTC
Workaround:

Add a new file to your project, set the Build action to LinkDescription, and add the contents:

  <linker>
    <assembly fullname="Mono.Android">
      <type fullname="Android.Widget.AdapterView">
        <method name="GetGetAdapterHandler" />
        <method name="GetSetAdapter_Landroid_widget_Adapter_Handler" />
      </type>
    </assembly>
  </linker>

See also: http://docs.xamarin.com/guides/android/advanced_topics/linking/
Comment 4 softlion 2014-01-03 03:42:38 UTC
My real problem is here: http://stackoverflow.com/questions/20873303/linker-and-layoutinflater-inflateint-android-views-viewgroup/20886344?noredirect=1#20886344

It seems it is not the exact same missing method.

But i don't know how to find out which one is missing.

Should i decompile Android.Views.LayoutInflater.Inflate and look at the method called in CallObjectMethod ?
Comment 5 Jonathan Pryor 2014-01-03 10:48:13 UTC
What target device are you running on? Can you run on Android Jelly Bean v4.1 or later?

Are you looking at the IDE's Application Output window or `adb logcat`? You'll want to read `adb logcat`. :-)

When I was running the app on a Nexus 5/Android v4.4, I got a more useful error message:

> E/mono-rt (22977): [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: Couldn't bind to method 'GetGetAdapterHandler'.
> E/mono-rt (22977):   at System.Delegate.GetCandidateMethod (System.Type type, System.Type target, System.String method, BindingFlags bflags, Boolean ignoreCase, Boolean throwOnBindFailure) [0x00000] in <filename unknown>:0 
> E/mono-rt (22977):   at System.Delegate.CreateDelegate (System.Type type, System.Type target, System.String method, Boolean ignoreCase, Boolean throwOnBindFailure) [0x00000] in <filename unknown>:0 
> E/mono-rt (22977):   at System.Delegate.CreateDelegate (System.Type type, System.Type target, System.String method) [0x00000] in <filename unknown>:0 
> E/mono-rt (22977):   at Android.Runtime.JNIEnv.RegisterJniNatives (IntPtr typeName_ptr, Int32 typeName_len, IntPtr jniClass, IntPtr methods_ptr, Int32 methods_len) [0x00000] in <filename unknown>:0 
> E/mono-rt (22977):   at (wrapper managed-to-native) object:wrapper_native_0x414f8c11 (intptr,intptr,intptr,intptr,Android.Runtime.JValue[])
> E/mono-rt (22977):   at (wrapper delegate-invoke) <Module>:invoke_void__this___intptr_intptr_intptr_intptr_JValue[]

It doesn't tell you want type it's checking (unfortunately), but it does provide the method name, which is how I got the method names for Comment #3.

Once I fixed GetGetAdapterHandler(), it still failed, which is how I found GetSetAdapter_Landroid_widget_Adapter_Handler():

> I/MonoDroid(23686): UNHANDLED EXCEPTION: System.ArgumentException: Couldn't bind to method 'GetSetAdapter_Landroid_widget_Adapter_Handler'.
> I/MonoDroid(23686): at System.Delegate.GetCandidateMethod (System.Type,System.Type,string,System.Reflection.BindingFlags,bool,bool) <IL 0x00129, 0x002bc>
> I/MonoDroid(23686): at System.Delegate.CreateDelegate (System.Type,System.Type,string,bool,bool) <IL 0x0001e, 0x0005f>
> I/MonoDroid(23686): at System.Delegate.CreateDelegate (System.Type,System.Type,string) <IL 0x00005, 0x00033>
> I/MonoDroid(23686): at Android.Runtime.JNIEnv.RegisterJniNatives (intptr,int,intptr,intptr,int) <IL 0x0022f, 0x006ff>
> I/MonoDroid(23686): at (wrapper managed-to-native) object.wrapper_native_0x414f8c11 (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0x0004f>
> I/MonoDroid(23686): at (wrapper delegate-invoke) <Module>.invoke_void__this___intptr_intptr_intptr_intptr_JValue[] (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <IL 0x00062, 0x000cb>
> I/MonoDroid(23686): at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <IL 0x00073, 0x000bf>
> I/MonoDroid(23686): at Android.App.Activity.SetContentView (int) <IL 0x00099, 0x001cf>
> I/MonoDroid(23686): at Cheesebaron.HorizontalListView.Demo.Activity1.OnCreate (Android.OS.Bundle) <IL 0x0000d, 0x00033>
> I/MonoDroid(23686): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <IL 0x00013, 0x0005b>
> I/MonoDroid(23686): at (wrapper dynamic-method) object.95d8a3d3-6280-4258-a5a4-c07757ff794d (intptr,intptr,intptr) <IL 0x00017, 0x00043>

That's a particularly handy stack trace, as the SetContentView() call lets us know that we're reading a Layout .xml file, inspection of which leads us to the <cheesebaron.horizontallistview.HorizontalListView/> element and the HorizontalListView type, which inherits AdapterView<BaseAdapter>, so the "missing" methods are coming from AdapterView.

> Should i decompile Android.Views.LayoutInflater.Inflate and look at the method
> called in CallObjectMethod ?

That's unlikely to help, as it'll just be another JNIEnv.Call*Method() invocation. Reading the Java LayoutInflator.inflate() source won't help either, as it's reading and operating based on the Layout .axml file. In short, everything here is "dynamic"/reflection/runtime-based; IL disassembly won't help.

Once you know what method you're missing -- from the ArgumentExceptions above -- IL disassembly _will_ help in finding out what type they're declared on.
Comment 6 softlion 2014-01-03 18:56:31 UTC
> What target device are you running on? Can you run on Android Jelly Bean v4.1
or later?

I run on the simulator Android 4.3 (x86/HAX).

> Are you looking at the IDE's Application Output window or `adb logcat`? You'll
want to read `adb logcat`. :-)

Yes but i prefer the logcat reader tab in the "android debug monitor" tool. It features a scroll lock which is missing from VS. And it is very fast, much more than the VS one. You can't copy lines from it though.

> When I was running the app on a Nexus 5/Android v4.4, I got a more useful error
message

So on Android 4.4 the messages are more detailed ? I don't have other details on 4.3. The stack stops at (wrapper managed-to-native).

Will you provide a fix in an upcoming version ? This used to work ok. And i don't have more time to find a workaround for this problem.
Comment 7 Jonathan Pryor 2014-01-07 16:25:36 UTC
> So on Android 4.4 the messages are more detailed 

They shouldn't be; IIRC I got full unhandled exception messages under Android v4.3 on my Nexus 10. I'm surprised you don't get more info. :-(
Comment 8 Atsushi Eno 2014-07-30 16:38:51 UTC
Back to the original linking issue, I searched for "GetAdapter" in the sources and I could not find any explicit invocation of that member. With that I rather think it is not a bug but the case where developers have to explicitly write LinkDescription in the application project.

Maybe there was some stale build after adding LinkDescription? I added the file and the exception is gone. Please try clean build and see if that exception still occurs. I could successfully kill the error with my LinkDescription.xml.
Comment 9 softlion 2014-07-31 01:34:31 UTC
it's an old report, lists seems to work fine now.