0

I had fully working Xamarin.Forms (Android and iOS). HAXM is running. Then I installed CocosSharp from nuget in my PCL project and both Android and iOS projects. iOS project works great but Android... not.

I have:

'Resource.String' does not contain a definition for `ApplicationName' 
'Resource.String' does not contain a definition for `Hello'

I looked for a solution, but all I found is that I have to Clean the solution. I did. It didn't work. I even closed the Visual Studio, removed packages folder, removed all bin/obj projects. Opened VS, again cleaned solution (just in case), rebuilt. The same error.

How can I fix this? Should I manually add String.xml to the project? Really?!

Thanks for help

Ish Thomas
  • 2,270
  • 2
  • 27
  • 57

1 Answers1

2

How can I fix this? Should I manually add String.xml to the project? Really?!

I made a demo and reproduced your problem. By opening the Resource.Designer.cs file I found that the following codes are automatically added to UpdateIdValues():

global::CocosSharp.Forms.Android.Resource.String.ApplicationName = global::CocosSharpDemo.Droid.Resource.String.ApplicationName;
global::CocosSharp.Forms.Android.Resource.String.Hello = global::CocosSharpDemo.Droid.Resource.String.Hello;

By commenting out/deleting these two lines of codes, the application builds and runs correctly.

Or, of course adding a strings.xml file with following codes to values folder also fix the problem:

<resources>
    <string name="ApplicationName">your project name</string>
    <string name="Hello">hello</string>
</resources>

I have opened an issue on the project's Github.

Elvis Xia - MSFT
  • 10,801
  • 1
  • 13
  • 24
  • Thanks, but `Resource.Designer.cs` is generated automatically. So it will not fix the problem. With second solution I came out myself and it works, but I don't think it's the right solution. I mean, the problem is 3 years old (according to some posts online) - are you telling me that people manually creates strings.xml for past 3 years and Xamarin just ignores it? – Ish Thomas Jan 17 '17 at 03:04
  • I ran some more tests. It turns out rebuilding the project regenerates the two lines of codes. So currently the best workaround is to add the `strings.xml` file to values folder. I'm not the author of this framework library. I don't know why these two lines of codes are added automatically. And that's why I opened up an [issue](https://github.com/mono/CocosSharp/issues/408) on the project's github. Let's wait for the response. – Elvis Xia - MSFT Jan 17 '17 at 03:12
  • Thanks, Let's see. But that's strange.. the problem was there almost 3 years ago. There must be similar problem opened already. I think... – Ish Thomas Jan 18 '17 at 06:17