Bug 59134 - build error from create a class to subclass the Android.Support.V7.Widget.RecyclerView.Adapter and implement the interface Android.Widget.IAdapter
Summary: build error from create a class to subclass the Android.Support.V7.Widget.Rec...
Status: REOPENED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 7.4 (15.3)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2017-08-31 07:21 UTC by ericcui
Modified: 2017-09-01 01:48 UTC (History)
2 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 for Bug 59134 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 original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
REOPENED

Description ericcui 2017-08-31 07:21:02 UTC
1. Use VS2015 create android project
2. Install-Package Xamarin.Android.Support.v7.AppCompat -Version 25.4.0.2 
3. Install-Package Xamarin.Android.Support.v7.RecyclerView -Version 25.4.0.2 
4. create a class ,public class TestClass : Android.Support.V7.Widget.RecyclerView.Adapter, IAdapter
5. implement the TestClass' all method from parent and interface.
6. rebuild project 
7. ouput windows throw error:

1>  obj\Debug\android\src\md5897b419a19f283220a9c13047f2516c6\TestClass.java:72: 閿欒: TestClass涓殑hasStableIds()鏃犳硶瑕嗙洊Adapter涓殑hasStableIds()
1>  	public boolean hasStableIds ()
1>  	               ^
1>    琚鐩栫殑鏂规硶涓篺inal
1>  娉? 鏌愪簺杈撳叆鏂囦欢浣跨敤鎴栬鐩栦簡宸茶繃鏃剁殑 API銆?
1>  娉? 鏈夊叧璇︾粏淇℃伅, 璇蜂娇鐢?-Xlint:deprecation 閲嶆柊缂栬瘧銆?
1>  娉? 鏌愪簺杈撳叆鏂囦欢浣跨敤浜嗘湭缁忔鏌ユ垨涓嶅畨鍏ㄧ殑鎿嶄綔銆?
1>  娉? 鏈夊叧璇︾粏淇℃伅, 璇蜂娇鐢?-Xlint:unchecked 閲嶆柊缂栬瘧銆?
1>  1 涓敊璇?
1>D:\TempApps\BugAndroidApp\BugAndroidApp\obj\Debug\android\src\md5897b419a19f283220a9c13047f2516c6\TestClass.java(72,17): javac.exe error :  閿欒: TestClass涓殑hasStableIds()鏃犳硶瑕嗙洊Adapter涓殑hasStableIds()
1>D:\TempApps\BugAndroidApp\BugAndroidApp\obj\Debug\android\src\md5897b419a19f283220a9c13047f2516c6\TestClass.java(72,17): javac.exe error : 	public boolean hasStableIds ()
1>D:\TempApps\BugAndroidApp\BugAndroidApp\obj\Debug\android\src\md5897b419a19f283220a9c13047f2516c6\TestClass.java(72,17): javac.exe error :   琚鐩栫殑鏂规硶涓篺inal
1>D:\TempApps\BugAndroidApp\BugAndroidApp\obj\Debug\android\src\md5897b419a19f283220a9c13047f2516c6\TestClass.java(72,17): javac.exe error : 娉? 鏌愪簺杈撳叆鏂囦欢浣跨敤鎴栬鐩栦簡宸茶繃鏃剁殑 API銆?
1>D:\TempApps\BugAndroidApp\BugAndroidApp\obj\Debug\android\src\md5897b419a19f283220a9c13047f2516c6\TestClass.java(72,17): javac.exe error : 娉? 鏈夊叧璇︾粏淇℃伅, 璇蜂娇鐢?-Xlint:deprecation 閲嶆柊缂栬瘧銆?
1>D:\TempApps\BugAndroidApp\BugAndroidApp\obj\Debug\android\src\md5897b419a19f283220a9c13047f2516c6\TestClass.java(72,17): javac.exe error : 娉? 鏌愪簺杈撳叆鏂囦欢浣跨敤浜嗘湭缁忔鏌ユ垨涓嶅畨鍏ㄧ殑鎿嶄綔銆?
1>D:\TempApps\BugAndroidApp\BugAndroidApp\obj\Debug\android\src\md5897b419a19f283220a9c13047f2516c6\TestClass.java(72,17): javac.exe error : 娉? 鏈夊叧璇︾粏淇℃伅, 璇蜂娇鐢?-Xlint:unchecked 閲嶆柊缂栬瘧銆?
1>D:\TempApps\BugAndroidApp\BugAndroidApp\obj\Debug\android\src\md5897b419a19f283220a9c13047f2516c6\TestClass.java(72,17): javac.exe error : 1 涓敊璇?
1>D:\TempApps\BugAndroidApp\BugAndroidApp\obj\Debug\android\src\md5897b419a19f283220a9c13047f2516c6\TestClass.java(72,17): javac.exe error : 
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Comment 1 Jon Douglas [MSFT] 2017-08-31 16:02:14 UTC
Hi Eric,

Thanks for the bug report! We really appreciate you taking the time and effort to report an issue.

I don't see Xamarin version information in your post, in the future, can you please add that to your posts? You can find it in Help -> About Visual Studio. This will help us ensure we are testing against the right version!

The problem from a first glance is that:

RecyclerView.Adapter has a property:

public bool HasStableIds { get; set; }

Also IAdapter has a propery:

bool HasStableIds { get; }

Thus the error is saying it cannot override it, which it cannot. Instead, you simply only need the "RecyclerView.Adapter" and you do not need to include the "IAdapter" interface in this case.

Here's a sample for good measure!

https://github.com/xamarin/monodroid-samples/blob/fb9d4ed266bdf68bb1f9fa9933130b285712ec82/android5.0/RecyclerViewSample/RecyclerViewSample/CustomAdapter.cs#L9

IAdapter is used for normal adapters such as BaseAdapter:

https://developer.xamarin.com/api/type/Android.Widget.BaseAdapter/

(Where IListAdapter and ISpinnerAdapter implements IAdapter)
Comment 2 ericcui 2017-09-01 01:48:45 UTC
Hello,
the xamarin version is 4.6.0.299
the xamarin.android version is 7.4.0.21

Thanks for your answer, 
Actually,I am doing a java library to xamarin android ,the library here:
https://github.com/scwang90/SmartRefreshLayout

I had finished the library binding.
And I Start to "copy" some sample from the app code to the xamarin android blank app.

One sample page which in all pages have this feature:
https://github.com/scwang90/SmartRefreshLayout/blob/master/app/src/main/java/com/scwang/refreshlayout/adapter/BaseRecyclerAdapter.java

BaseRecyclerAdapter<T> extends RecyclerView.Adapter<SmartViewHolder> implements ListAdapter 

and this code call this class:

https://github.com/scwang90/SmartRefreshLayout/blob/master/app/src/main/java/com/scwang/refreshlayout/activity/style/MaterialStyleActivity.java

After I finished all copy form those java class to c#.
The VS thorw error while I rebuild the app.

So I create a blank app to simulate this feature,create a class and subclass the Android.Support.V7.Widget.RecyclerView.Adapter,implement IAdapter interface .
So the compile error show again.

I'll try to remove the interface ,hope that it can not deviate the effect of the java app.
Thanks.