Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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 for Bug 22313 on
Developer Community or GitHub if you have new
information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
Created attachment 7775 [details]
The [Export] custom attribute doesn't support generic types on parameters or return types.
1. Download Attachment #7775 [details].
Expected results: it builds (maybe?)
> error XA4209: Failed to create JavaTypeInfo for class: Scratch.ExportCollections.MyPreferences due to System.NullReferenceException: Object reference not set to an instance of an object
> at Xamarin.Android.Tasks.JavaTypeInfo+Signature..ctor (System.String name, System.String signature, System.String connector, System.String managedParameters, System.String outerType, System.String superCall)
> at Xamarin.Android.Tasks.JavaTypeInfo+Signature..ctor (Mono.Cecil.MethodDefinition method, Java.Interop.ExportAttribute export)
> at Xamarin.Android.Tasks.JavaTypeInfo.AddMethod (Mono.Cecil.MethodDefinition registeredMethod, Mono.Cecil.MethodDefinition implementedMethod)
> at Xamarin.Android.Tasks.JavaTypeInfo..ctor (Mono.Cecil.TypeDefinition type, System.String outerType, System.Object log)
> at Xamarin.Android.Tasks.JavaTypeInfo..ctor (Mono.Cecil.TypeDefinition type, System.Object log)
> at Xamarin.Android.Tasks.Generator.GenerateJavaSource (Microsoft.Build.Utilities.TaskLoggingHelper log, Mono.Cecil.TypeDefinition t, System.String outputPath, Boolean useSharedRuntime, Boolean hasExportReference)
The cause for the exception is this method:
> [Java.Interop.Export ("getStringSet")]
> public System.Collections.Generic.ICollection<string> GetStringSet (string key, System.Collections.Generic.ICollection<string> defValues)
> return base.GetStringSet (key, defValues);
The ACW generator can't create a JNI name for e.g. `ICollection<string>`, returns null, and things fail from there.
The reason for wanting this method is to work around a different bug/issue
What's happening in the above is that they're binding a Java library ("oak") which provides a custom android.content.SharedPreferences subclass, but the .jar is build against API-10. As such, the custom type is "missing" the SharedPreferences.getStringSet() method (added in API-11), and the binding project + Application are setting $(TargetFrameworkVersion) to v4.0 (API-14).
Getting the binding project building is easy enough -- add a partial class which implements ISharedPreferences.GetStringSet().
Things fall to pieces when you try to SUBCLASS the SharedPreferences type, because the bound type doesn't provide SharedPreferences.getStringSet(), and the android.jar that javac is using has SharedPreferences.getStringSet(), so javac requires that the (non-abstract) "C#" subclass have that method, which doesn't exist.
The obvious answer: Add the "missing" GetStringSet() method, and [Export] it.
Unfortunately that fails (Comment #1).
The "correct" workaround is to provide the [Register] attribute on the binding's implementation of GetStringSet(), and then override GetStringSet() in the C# subclass so that the ACW declares getStringSet().
I have checked this issue and able to reproduce this issue. To reproduce this issue I have followed the steps provided in bug description.
Steps I followed:
1. Open attached sample application in XS
2. Build the application
3. On building, you will get following building error.
Error : https://gist.github.com/Rajneesh360Logica/5e468e6761a4a9eb540d
Build Output: https://gist.github.com/Rajneesh360Logica/2d754f41b238d07541eb
=== Xamarin Studio ===
Version 5.5.3 (build 6)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Mono 3.10.0 ((detached/e204655)
GTK+ 2.24.23 (Raleigh theme)
Package version: 310000023
=== Xamarin.Android ===
Version: 4.18.0 (Business Edition)
Android SDK: /Users/MM/Desktop/android-sdk-macosx
Supported Android versions:
2.1 (API level 7)
2.2 (API level 8)
2.3 (API level 10)
3.1 (API level 12)
3.2 (API level 13)
4.0 (API level 14)
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.3 (API level 18)
4.4 (API level 19)
4.4.87 (API level 20)
4.5 (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
=== Apple Developer Tools ===
Xcode 6.0.1 (6528)
=== Xamarin.iOS ===
Version: 220.127.116.11 (Business Edition)
Build date: 2014-10-20 21:48:06-0400
=== Xamarin.Mac ===
Version: 18.104.22.168 (Business Edition)
=== Build Information ===
Release ID: 505030006
Git revision: fbe3e9453daf6a3bb9a9709ed22bec35f7c9056b
Build date: 2014-10-23 13:08:38-04
Xamarin addins: e44add2b39de4dd57c0742bb2e620dfad84c64c6
=== Operating System ===
Mac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
Sun Aug 17 19:50:11 PDT 2014