Project fails to build with same errors

RonNYCRonNYC Member ✭✭✭
edited November 29 in Xamarin.Android

There are two: One error is supposedly in activity_mail.axml. Most of the time at line 114 but sometimes at line 117.

Either those lines are blank or they contain perfectly valid axml.

Even if I add lines before 114 (or 117), the error is still at 114 or 117.

It's a Linear Layout, with a table layout followed by 8 table rows with contain EditViews, TextViews and Buttons.

This is axml that (1) hasn't been changed in a while and (2) previous, like earlier today, compiled just fine and ran on my phone just fine.

Additionally, I find these inserted into the axml:

         <TextView
            android:minWidth="30px"
            android:minHeight="30px"
            xmlns="http://schemas.android.com/apk/res/android"
            android:id="@+id/textView4" />
        <TextView
            android:minWidth="30px"
            android:minHeight="30px"
            xmlns="http://schemas.android.com/apk/res/android"
            android:id="@+id/textView5" />
        <TextView
            android:minWidth="30px"
            android:minHeight="30px"
            xmlns="http://schemas.android.com/apk/res/android"
            android:id="@+id/textView6" />

When it occurs, there are 5 or 6 groups of them. Always the same. Always in groups of 3 and the width and height are always 30px.

Today was by far the worst. Each time I rebuild the app, the build fails as these groups are inserted into the axml.

I'm using VS 2019 (Community) Version 16.3.9.

I can't make the axml read only as that (for no reason I can understand) causes the build to fail.

The axml usually renders just fine in VS.

Tagged:

Best Answer

  • RonNYCRonNYC ✭✭✭
    Accepted Answer

    I exited VS a few times, deleted the bin and obj folders, etc., and for some reason, now I can add new Resource.Ids.

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    I don't remember when but now the VS consumes and generates .xml files instead of .axml files. If you used the latest VS to open the old projects it will automatically generate a corresponding .xml file to keep compatible. You could try to find the .xml which has the same name of the .axml file. Maybe, the extra code is laid there. You could read the thread discussing them here:
    https://forums.xamarin.com/discussion/comment/395807

  • RonNYCRonNYC Member ✭✭✭

    Those 30px textview sections just appear, like all of a sudden. Usually 5 sections plus one or two extras.

    WHY?

  • RonNYCRonNYC Member ✭✭✭
    edited December 2

    VS only created one xml file. I'm not sure it's purpose. It seems useless. The only changes that have any effect are those to the axml file.

    But none of these explains what process inserts those lines into the axml.

    It's kind of exhausting spending so much time getting the code right only to have some weird, apparently totally unknown process, just insert itself into my code and screw things up.

  • LandLuLandLu Member, Xamarin Team Xamurai

    Try to check the .xml files did the code lay there to modify your axml. files again and again.
    It's best to share the sample here to help me look into this issue. If it's hard to reproduce it in a sample you could try to open a support ticket here:
    https://support.microsoft.com/en-us/supportforbusiness/productselection?sapId=211dd84f-3474-c3c5-79bf-66db630c92a6

  • RonNYCRonNYC Member ✭✭✭
    edited December 4

    I did open a ticket. It is still going on. And now my MainActivity.cs code cannot find a resource id:

                                    <Button 
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content" 
                        android:id="@+id/btnRecipients"
                        android:textSize="12dp" 
                        android:layout_weight=".25"
                        android:theme="@style/CustomButton"
                        android:textStyle="normal"
                        style="@style/Widget.AppCompat.Button.Colored"
                                                android:text="Recipients" />
    
                     btnEmailRecipients = (Button)FindViewById(Resource.Id.btnRecipients);
    

    I've exited VS, deleted the bin and obj folders and deleted Resource.Designer.cs; restarted VS and...same error. Of course I have to constantly delete the 6 groups of:

              <TextView
                android:minWidth="30px"
                android:minHeight="30px"
                xmlns="http://schemas.android.com/apk/res/android"
                android:id="@+id/textView7" />
            <TextView
                android:minWidth="30px"
                android:minHeight="30px"
                xmlns="http://schemas.android.com/apk/res/android"
                android:id="@+id/textView8" />
            <TextView
                android:minWidth="30px"
                android:minHeight="30px"
                xmlns="http://schemas.android.com/apk/res/android"
                android:id="@+id/textView9" />
    

    I mean, what is going on?

    Trying to work through this strange marriage of VS/C#, Xamarin, Mono, Java and Android is hard enough but when the dev environment turns against you, well, it just makes it very very difficult.

    And now the build fails because "not well formed (invalid) token":

    <TableRow
                android:id="@+id/tableRow6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.25"
                    android:padding="10dp"
                    android:text="Use Paste Key or Set Key"                     
                        android:id="@+id/KeyTextLabel" /> 
               </TableRow>
    

    Today is BY FAR THE WORST. I've had to delete those 30px entries SIX TIMES so far. Today I have spent maybe 90% of the time trying to get the thing to build, deleting those weird rows, trying to figure out why a Resource.Id cannot be found, etc. Is Xamarin becoming the Your Phone Companion of development? I hope not.

  • LandLuLandLu Member, Xamarin Team Xamurai

    As I said above VS now starts consuming .xml files. If you only modified the .axml files the xml will automatically revert it back to what it was like in xml. And if you only named the controls in axml the id could not be recognized by the designer. This issue will occur when you open an old project using the latest VS and it's the time to migrate from axml to xml.

  • RonNYCRonNYC Member ✭✭✭
    edited December 5

    Somehow what you said didn't quite register. I excluded the axml from the project but that didn't solve the problem.

    I have edited the xml in Notepad++ so at least the weird textviews being inserted into the file don't happen.

    HOWEVER, VS seems unaware of any new Resource.Ids that I add to the xml.

  • RonNYCRonNYC Member ✭✭✭

    My workaround is to edit the xml in Notepad++ and never try to render it in VS. This seems to be working. I noticed that the corresponding axml is not updated so I excluded it from the project.

    HOWEVER, VS is not aware of new Resource.Ids. I have no idea what to do.

  • RonNYCRonNYC Member ✭✭✭
    Accepted Answer

    I exited VS a few times, deleted the bin and obj folders, etc., and for some reason, now I can add new Resource.Ids.

Sign In or Register to comment.