I'm coming, one more time, after deep search on google and as usual, I can't find the answer which can solves my problem...
I have these 3 errors:
Error CS0117 'Resource.Layout' does not contain a definition for 'NativeAndroidCell' Error CS0117 'Resource.Id' does not contain a definition for 'Ride' Project.Droid Error CS0117 'Resource.Id' does not contain a definition for 'Since' Project.Droid
from this c# code
public class NativeAndroidCellRenderer : ViewCellRenderer { protected override Android.Views.View GetCellCore(Xamarin.Forms.Cell item, Android.Views.View convertView, ViewGroup parent, Context context) { var x = (NativeCell)item; var view = convertView; if (view == null) { // no view to re-use, create new view = (context as Activity).LayoutInflater.Inflate(Android.Resource.Layout.NativeAndroidCell, null); //'Resource.Layout' does not contain a definition for 'NativeAndroidCell' } view.FindViewById<TextView>(Android.Resource.Id.Ride).Text = x.Ride; //'Resource.Id' does not contain a definition for 'Ride' view.FindViewById<TextView>(Android.Resource.Id.Since).Text = x.Since; //'Resource.Id' does not contain a definition for 'Since' return view; } }
So, I saw that it can comes from the build action
so I set it to AndroidResource
The content is the following:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentStart="true" android:orientation="vertical" android:padding="10dp" android:background="#FFFFFF"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#FF0000" android:gravity="center"> <TextView android:id="@+id/Ride" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:text="Caen - Narbonne" android:textColor="#FFFFFF" android:textSize="30dp" /> <TextView android:id="@+id/Since" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:gravity="center_vertical" android:text="6mins." android:textColor="#FFFFFF" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#FFFFFF"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentLeft="true" android:orientation="horizontal" android:gravity="center_vertical"> <TextView android:id="@+id/Duration" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="19mins" android:textColor="#000000" android:layout_weight="0" android:padding="5dp" /> <TextView android:id="@+id/Pseudo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Emixam23" android:textColor="#000000" android:layout_weight="0" android:padding="5dp" /> <TextView android:id="@+id/StopNumber" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="1 arret" android:textColor="#000000" android:layout_weight="0" android:padding="5dp" /> </LinearLayout> <Button android:id="@+id/More" android:layout_width="45dp" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:text="+" /> <Button android:id="@+id/Agree" android:layout_width="45dp" android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:text="V" /> </RelativeLayout> </LinearLayout> </RelativeLayout>
As you can see, this NativeAndroidCell.axml
seems all right, so what is happening? my Resource.Designer.cs has a build action of Compile
I'm juste trying to follow the tutorial of Customizing a ViewCell
If anyone can help, thank !
Yep, I mean, I think so..
You want the last update of the nuget package for android? Then update your android lib from the Android SDK Manager.
I think if you want the last update, you need Android 8, but you have to try and confirm
Best,
Max
Answers
@Emixam23 - Just as a first port of call, try deleting everything inside the Resource.Designer.cs file. Then rebuild your application. I find the Resource.Designer.cs doesn't rebuild nearly as often as it should and you need to wipe it out before it rebuilds again.
I'm again on that problem today haha, so weird because I deleted it and nothing changed, it doesn't recreate it anyway
I am also in same problem there is no ID property in Resource class ex ...FindViewById(findViewById.Resource.Id); there is no Id Property
I found a solution, maybe it's not the thing that solves it, maybe yes, but if (from the Android SDK manager sandlone) you have the last version etc of the packages Android, then update the Android nugget that you have (they should be 23.3.0 something like that, update them to the last version so everything will match and then, it'll work. Before try that on your project, test from another solution
Best,
Max
Great tip. I've been trying to solve this problem for a long time. Thank you!
Did anyone get any solution for this? Also having the same problem and I didn't have any luck from updating the android nugget. Thanks guys
Yep, I mean, I think so..
You want the last update of the nuget package for android? Then update your android lib from the Android SDK Manager.
I think if you want the last update, you need Android 8, but you have to try and confirm
Best,
Max
The best and easy solution is clear the Main.axml page and Reset and it is working.




In my case, I was receiving resource related errors, but my solution itself would still compile. It's still annoying though to have the error list littered with false errors. It seems something in the .vs folder within my solution must have become corrupt. None of the other recommendations I tried were successful, but once I deleted the .vs folder, cleaned my solution and then re-opened studio, I no longer received the false errors. I would recommend trying this for anyone who has a similar situation.
I also copy-pasted code from another project into an *.axml layout file, and got this error. Here's what solved it for me: I simply added a new Button in the *.axml file, saved it, built it, and it worked. Afterwards I removed the Button, and it still worked. Not sure what causes this, but my guess is that inside the Resource.Designer.cs file you see this Attribute on the class:
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
And it seems that the way the compiler interprets this is that a copy-paste doesn't qualify as file modification, but if you actually edit it with the cursor and type, then that does. ¯\_(ツ)_/¯
this helped me, thanks
This has plagued me off and on. Project would build but would not deploy. I would the "resouce. does not contain.....etc". What was the culprit for me was excess white space in the axml file. I would have elements where I put the "/>" on another line for ease. Well... it don like that. No white space in the after the last attribute and all of my problems went away. Another Xamarin ooops!1
Solved this error by saving .axml, cleaning project and finally building project
This did it for me. Thanks!
I'm glad I was able to help.
I changed the [Properties/Build Action] for each file generating that error to [Android Resource] instead of [Compile] and that worked for me
Hi devs,
I personally fixed this issue deleting the obj folder in the project directory.