Android Class Libraries and String Resources

BradRobinsonBradRobinson AUMember ✭✭✭

I've got an Android app with a couple of Android class libraries. The class libraries have no string resources but I keep getting errors in resource.designer.cs UpdateIdValues() for strings that have been deleted. I'm not even sure how to explain it except to say that something in the tool chain keeps putting back resource ids that have been deleted.

I've tried full rebuilds, putting strings in, taking them out and just can't get this project to build.

Is there some way I can tell the build process to forget everything it used to know about strings and start again?

Running XamStudio 4.0.3 on OSX.

Posts

  • BradRobinsonBradRobinson AUMember ✭✭✭
    edited March 2013

    This is pretty easy to reproduce:

    1. Create an android app TestApp
    2. Create two Android library projects TestLib1 and TestLib2
    3. Set TestApp to reference TestApp1 and TestApp2
    4. Build works.
    5. In each lib project remove the string "library_name"
    6. Build works (but suspicious it's wrong)
    7. Rebuild fails with:

    --

    TestLib1.Resource.String.library_name = TestApp.Resource.String.library_name;
    TestLib2.Resource.String.library_name = TestApp.Resource.String.library_name;
    
    Resources/Resource.designer.cs(29,89): error CS0117: `TestApp.Resource.String' does not contain a definition for `library_name'
    Resources/Resource.designer.cs(30,89): error CS0117: `TestApp.Resource.String' does not contain a definition for `library_name'
    
  • BradRobinsonBradRobinson AUMember ✭✭✭

    Oh, Clean All seems to fix this.

    So it seems there's something wrong with the dependency management with strings. Continuing on from the above steps:

    1. Clean All + Build All - works (whereas Rebuild wont)
    2. Now change the name (not the value) of one of the lib strings (eg: "library_name" to "lib1_name")
    3. Build succeeds, but if you look at the app's resource.designer.cs it still has the old string id.
    4. Rebuild fails.
    5. Clean All + Build All works
    6. Now delete the strings from both libraries
    7. Build works, but app's resource.designer.cs still has the string ids.
    8. Clean All + Build All - fails

    At this stage, it seems nothing you do will get the project to build again - you have to put at least one string in each lib project then Clean, then Build.

    So, in summary:

    • Rebuild All is not the same as Clean All followed Build All
    • Lib projects with no string resources are a no go - always include at least one string
    • Don't trust what you're seeing in Resource.Designer.cs - it doesn't reload when the tool chain updates the file, close and reopen the file to see up to date content.
    • After adding or removing a string from a lib project, always do a Clean All.
  • BradRobinsonBradRobinson AUMember ✭✭✭

    Oh no! It seems any code change in the lib projects causes the build to fail. So now I need to Clean All + Build All for every build.

    Productivity just took a massive dive!

  • BradRobinsonBradRobinson AUMember ✭✭✭

    In my real-world project any code change in the libs requires me to clean + build the entire solution to get it to build. I've not been able to reproduce this in a test app though.

  • BradRobinsonBradRobinson AUMember ✭✭✭

    Sometimes, after a code change if I just hit build again it works... sometimes I need to hit build 3 times and it finally works. Something seriously broken here.

  • BradRobinsonBradRobinson AUMember ✭✭✭

    Found a work around - delete either the strings.xml, or Resources folder from lib projects.

    If you delete the Resources folder, you need to close and re-open the project for it to disappear.

  • BeringelaBeringela GBMember

    I get same error, running XamStudio 4.0.3 on Win7.

    The Clean All, Build All fixed it, but it does keep coming back intermittently.

  • Ran into a similar error. Deleted the strings.xml file from the Resources/values folder and the build issue went away.

Sign In or Register to comment.