Bug 1403 - Can't deploy my app due to a bug in AdapterView<IAdapter>
Summary: Can't deploy my app due to a bug in AdapterView<IAdapter>
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 1.0
Hardware: PC Windows
: Highest major
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2011-10-10 17:08 UTC by El-Sayed Mohamed
Modified: 2012-01-23 14:53 UTC (History)
6 users (show)

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


Attachments
The attached project will reproduce the bug. (10.95 KB, application/octet-stream)
2011-10-10 17:08 UTC, El-Sayed Mohamed
Details


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 FIXED

Description El-Sayed Mohamed 2011-10-10 17:08:37 UTC
Created attachment 666 [details]
The attached project will reproduce the bug.

I can’t deploy my application to the emulator. The app build right but fail while trying to deploy with this error in the output build windows in visual studio 2010:

Mainly the error is due to missing method implementation. It is complaining about getAdapter returning wrong type & setAdapter is not implemented at all.
Third error, I can’t figure what it talks about.

Of course I have implemented the abstract Adapter property of the AdapterView class. Actually the code won’t compile if it is missing.

I'm using Mono for Android 1.2.0.24718 on Windows 7 with Visual Studio 2010.
------------------------------------------------------------------------

You can produce this bug simply by following these steps:
1- Open visual studio and create a new Mono for Android application.
2- Add a new class named ‘MyAdapter’.
3- Let the new class extend ‘AdapterView<IAdapter>’.
4- Implement the AdapterView<IAdapter> abstract class memebers. (Adapter, SelectedView, SetSelection(int position)).
5- Just let the members throw NotImplementedException.
6- Build.
7- Deploy (project deploy will fail).
--------------------------------------------------


This is the error shown in the output window:
------ Build started: Project: PanoramaControl, Configuration: Debug Any CPU ------
  PanoramaControl -> D:\PanoramaControl\bin\Debug\PanoramaControl.dll
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.237]
Copyright (C) Microsoft Corporation 2007. All rights reserved.

Build started 8/10/2011 4:51:21 AM.
Project "D:\PanoramaControl\PanoramaControl.csproj" on node 1 (SignAndroidPackage target(s)).
_GenerateAndroidAssetsDir:
Skipping target "_GenerateAndroidAssetsDir" because it has no outputs.
_ResolveMonoAndroidSdks:
  Looking for Android SDK..
    Key HKCU\SOFTWARE\Android SDK Tools\Path not found.
    Key HKLM\SOFTWARE\Android SDK Tools\Path found:
      Path contains adb.exe in \platform-tools (C:\Android\android-sdk).
  Looking for Java 6 SDK..
    Key HKLM\SOFTWARE\JavaSoft\Java Development Kit\CurrentVersion found.
    Key HKLM\SOFTWARE\JavaSoft\Java Development Kit\1.6\JavaHome found:
      Path contains jarsigner.exe in \bin (C:\Program Files\Java\jdk1.6.0_26).
  MonoAndroid Tools: C:\Program Files\MSBuild\Novell\
  MonoAndroid Framework: C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2\;C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\
  Android SDK: C:\Android\android-sdk\
  Java SDK: C:\Program Files\Java\jdk1.6.0_26\
_ValidateAndroidPackageProperties:
  GetAndroidPackageName Task
    ManifestFile: 
    AssemblyName: PanoramaControl
    PackageName: PanoramaControl.PanoramaControl
_UpdateAndroidResgen:
Skipping target "_UpdateAndroidResgen" because all output files are up-to-date with respect to the input files.
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
CopyFilesToOutputDirectory:
  PanoramaControl -> D:\PanoramaControl\bin\Debug\PanoramaControl.dll
_ConvertDebuggingFiles:
Skipping target "_ConvertDebuggingFiles" because all output files are up-to-date with respect to the input files.
_CompileAndroidPackage:
  Mandroid Task
    Assemblies: D:\PanoramaControl\bin\Debug\PanoramaControl.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2\Mono.Android.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.Linq.dll
    I18nAssemblies: 
    BuildDirectory: D:\PanoramaControl\obj\Debug\
    ReferenceAssembliesDirectory: C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2\;C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\;;
    AndroidSdkDirectory: C:\Android\android-sdk\
    JavaSdkDirectory: C:\Program Files\Java\jdk1.6.0_26\
    AssetDirectory: D:\PanoramaControl\obj\Debug\assets\
    AndroidSdkPlatform: 8
    MonoAndroidToolsDirectory: C:\Program Files\MSBuild\Novell\
    ResourceDirectory: D:\PanoramaControl\obj\Debug\res\
    ManifestTemplate: 
    Package: PanoramaControl.PanoramaControl
    NativeLibrary: 
    JavaSource: 
    Debug: True
    UseSharedRuntime: True
    SupportedAbis: armeabi
    LinkMode: None
    ExtraArgs:  
  C:\Program Files\MSBuild\Novell\mandroid.exe -v --nosign --sdk-dir="C:\Android\android-sdk" --builddir="D:\PanoramaControl\obj\Debug\android" --framework-dir="C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2" --framework-dir="C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0" -S="D:\PanoramaControl\obj\Debug\res" --package="PanoramaControl.PanoramaControl"   --nolink --abi="armeabi" --java-sdk-dir="C:\Program Files\Java\jdk1.6.0_26" --debug --sdk-platform="8" "D:\PanoramaControl\bin\Debug\PanoramaControl.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2\Mono.Android.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.Linq.dll" 
  MonoDroid.Utils.CommandFailedException: Operation is not valid due to the current state of the object
    at MonoDroid.Utils.ProcessRocks+<ReadStandardOutput>c__Iterator6.MoveNext () [0x00000] in <filename unknown>:0 
    at Monodroid.Toolbox.InvokeCommand (IEnumerable`1 commandLine) [0x00000] in <filename unknown>:0 
    at Monodroid.Toolbox.InvokeJavac (System.String src_path) [0x00000] in <filename unknown>:0 
    at Monodroid.Droidinator.CreateDalvikBytecode (System.Collections.Generic.List`1 javaTypes, System.Collections.Generic.List`1 assemblies) [0x00000] in <filename unknown>:0 
    at Monodroid.Droidinator.CreateApk () [0x00000] in <filename unknown>:0 
    at Monodroid.MainClass.Main (System.String[] argv) [0x00000] in <filename unknown>:0 
  D:\PanoramaControl\obj\Debug\android\src\panoramacontrol\controls\Panorama.java:4: panoramacontrol.controls.Panorama is not abstract and does not override abstract method setAdapter(android.widget.Adapter) in android.widget.AdapterView
  public class Panorama
         ^
  D:\PanoramaControl\obj\Debug\android\src\panoramacontrol\controls\Panorama.java:111: getAdapter() in panoramacontrol.controls.Panorama cannot override getAdapter() in android.widget.AdapterView; attempting to use incompatible return type
  found   : java.lang.Object
  required: android.widget.Adapter
                public java.lang.Object getAdapter ()
                                        ^
  D:\PanoramaControl\obj\Debug\android\src\panoramacontrol\controls\Panorama.java:110: method does not override or implement a method from a supertype
                @Override
                ^
  Note: Some input files use unchecked or unsafe operations.
  Note: Recompile with -Xlint:unchecked for details.
  3 errors
  
C:\Program Files\MSBuild\Novell\Novell.MonoDroid.Common.targets(399,2): error MSB6006: "mandroid.exe" exited with code 1. [D:\PanoramaControl\PanoramaControl.csproj]
Done Building Project "D:\PanoramaControl\PanoramaControl.csproj" (SignAndroidPackage target(s)) -- FAILED.

Build FAILED.

"D:\PanoramaControl\PanoramaControl.csproj" (SignAndroidPackage target) (1) ->
(_CompileAndroidPackage target) -> 
  C:\Program Files\MSBuild\Novell\Novell.MonoDroid.Common.targets(399,2): error MSB6006: "mandroid.exe" exited with code 1. [D:\PanoramaControl\PanoramaControl.csproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:10.60






Error: Cancelled
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========
Comment 4 El-Sayed Mohamed 2011-10-14 12:03:12 UTC
I have used AsbListView instead of AdapterView<IAdapter> with no luck.
So i think this bug is not related to generics limitation.

I wonder if this is the first time you see this behaviour?.

BTW, if I use ExpandableListView it does deploy. So I think the problem is
related to *abstratc* types.
Comment 10 Atsushi Eno 2011-10-20 08:21:59 UTC
Guys, any quick idea why it fails to retrieve Parent?
Comment 12 Atsushi Eno 2011-11-04 00:32:27 UTC
This might also be suffered from "types from different assembly" issue.
Comment 17 Jonathan Pryor 2012-01-20 11:48:36 UTC
An incorrect connector-method binding for AdapterView<T>.set_Adapter was fixed in 5e6684ed.
Comment 18 Jonathan Pryor 2012-01-20 15:42:59 UTC
Figured out the bug in Comment #7: the AdapterView<T> constructors are buggy and don't properly support Java-side activation.

Workaround: instead of inheriting from AdapterView<IAdapter>, inherit from AdapterView (non-generic), and override the RawAdapter property instead of the Adapter property.

Making this change allows Attachment #706 [details] to work for me.

Now to fix AdapterView<T>...
Comment 19 Jonathan Pryor 2012-01-20 16:04:55 UTC
The broken AdapterView<T> constructors are fixed in 6953a810, which allows Attachment #706 [details] to run as-is.

The original Attachment #666 [details] also builds, installs, and runs w/o error, so I deem this bug fixed.
Comment 20 El-Sayed Mohamed 2012-01-21 05:26:16 UTC
Thank you so much Jonathan.

Last question, can you please point me to the version that has this fix in order to be able to test it myself?.

Thanks,
El-Sayed
Comment 21 Jonathan Pryor 2012-01-23 14:53:17 UTC
It will be fixed in the forthcoming 4.2.0 release, which doesn't exist yet.

In the meantime I would suggest the workaround mentioned in Comment #18.