0

Using Visual Studio to develop a Xamarin cross platform APP. I have specific Android code I have added to the Android specific build. I get the CS0117 error when trying to compile. I have a 'V2T.axml' file in the Resources/layout folder. The line in the CS code with the error is:

SetContentView(Resource.Layout.V2T);

Any idea what is wrong?

Also get 2 more CS0117 errors for problems with 'Resource.Id" does not contain definition errors - but I have defined those two resources.

Any ideas?

CS:

    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        // set the isRecording flag to false (not recording)
        isRecording = false;

        // Set our view to: V2T.axml
        SetContentView(Resource.Layout.V2T);

        // get the resources from the layout
        recButton = FindViewById<Button>(Resource.Id.btnRecord);
        textBox = FindViewById<TextView>(Resource.Id.textYourText);

V2T.axml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="3">
<LinearLayout
    android:orientation="horizontal"
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/linearLayout1"
    android:layout_weight="1"
    android:gravity="center">
    <Button
        android:text="Start Recording"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/btnRecord" />
</LinearLayout>
<LinearLayout
    android:orientation="vertical"
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/linearLayout2"
    android:layout_weight="1">
    <TextView
        android:text="Your text"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView1"
        android:layout_marginLeft="5dp" />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/textYourText"
        android:textColor="#ffedf01d"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp" />
</LinearLayout>
<LinearLayout
    android:orientation="horizontal"
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/linearLayout3"
    android:layout_weight="1" />
 </LinearLayout>
  • consider post more code – John Joe Apr 19 '18 at 03:57
  • Here is code snippet: CS: protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // set the isRecording flag to false (not recording) isRecording = false; // Set our view to: V2T.axml SetContentView(Resource.Layout.V2T); // get the resources from the layout recButton = FindViewById – PizzaBoatJim Apr 19 '18 at 03:58
  • what is wrong in this line `SetContentView(Resource.Layout.V2T);` ? – John Joe Apr 19 '18 at 04:03
  • Not sure - I have used this exact code in a standalone APP and it worked. What am I missing? – PizzaBoatJim Apr 19 '18 at 04:06
  • please post the errors – John Joe Apr 19 '18 at 04:08
  • Severity Code Description Project File Line Suppression State Error CS0117 'Resource.Layout' does not contain a definition for 'V2T' EnSpect.Android D:\Other\Software\Xamarin\EnSpect\EnSpect\EnSpect.Android\Voice2Text.cs 28 Active – PizzaBoatJim Apr 19 '18 at 04:11
  • Severity Code Description Project File Line Suppression State Error CS0117 'Resource.Id' does not contain a definition for 'btnRecord' EnSpect.Android D:\Other\Software\Xamarin\EnSpect\EnSpect\EnSpect.Android\Voice2Text.cs 31 Active – PizzaBoatJim Apr 19 '18 at 04:11
  • Severity Code Description Project File Line Suppression State Error CS0117 'Resource.Id' does not contain a definition for 'textYourText' EnSpect.Android D:\Other\Software\Xamarin\EnSpect\EnSpect\EnSpect.Android\Voice2Text.cs 32 Active – PizzaBoatJim Apr 19 '18 at 04:11
  • have you read https://stackoverflow.com/questions/45393794/xamarin-resource-layout-does-not-contain-a-definition-for-tabbar-error ? – John Joe Apr 19 '18 at 04:14
  • I will go read that now. Will check back in a few – PizzaBoatJim Apr 19 '18 at 04:16
  • Still have the same problem. I updated to latest API, SDK & removed old versions. HOWEVER, I was not able to install the NDK - it kept failing. Do I need that? I found the NDK download site & currently downloading the latest – PizzaBoatJim Apr 19 '18 at 04:47
  • I downloaded NDK, but not sure how to have Visual Studio install it. Do I need this? As mentioned above, I have a standalone APP that works with this code. Just when I added it to my large APP project is when I get these errors. – PizzaBoatJim Apr 19 '18 at 05:06
  • I no idea about this..sorry – John Joe Apr 19 '18 at 06:05

1 Answers1

0

Clean Solution and rebuild, The layout xml wasn't built successfully That should solve it

Tolulope
  • 488
  • 1
  • 5
  • 19
  • When editing the CS code, the IntelliSense editor does not know about the 'V2T.axml' resource. As mentioned above, I copied files from a standalone CS project and put them into a larger Xamarin Forms projects with Android, iOS & Windows projects. I put everything into the Android project files. Do I need to specify the name space or project files when using the 'Resource.Layout.V2T' statement? How does that statement know to go look into my "EnSpect.Android" /Resources/layout folder to find V2T.axml? – PizzaBoatJim Apr 19 '18 at 17:47
  • IntelliSense does not see any files in 'Resource/Layout'. What am I missing? I have 'Tabbar.axml' & 'Toolbar.axml' also in that folder - but IntelliSense does not see them. – PizzaBoatJim Apr 19 '18 at 20:23
  • It is FIXED! I corrected my namespace in my CS file, from "EnSpect" to "EnSpect.Droid". Thanks to all who helped! – PizzaBoatJim Apr 19 '18 at 20:40