I was trying out the Xamarin Hello, Android Phoneword tutorial, and when I try to build the project, I get this error:
Error: String types not allowed (at 'id' with value ' @+id/CallButton'). (Phoneword)
What can I do to fix the error?
You have this:
android:id=" @+id/CallButton"
And you probably need this:
android:id="@+id/CallButton"
Notice I removed the empty space in front of the @.
Answers
Post the AXML content here (remember to mark it and press the C button in the toolbar) easier to see what is going on.
From the main.axml page :
<?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"> <TextView android:text="Enter a Phoneword:" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/textView1" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/PhoneNumberText" android:text="1-855-XAMARIN" /> <Button android:text="Translate" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/TranslateButton" /> <Button android:text="Call" android:layout_width="match_parent" android:layout_height="wrap_content" android:id=" @+id/CallButton" /> </LinearLayout>
The mainactivity.cs file :
`
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace Phoneword
{
[Activity (Label = "Phoneword", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
int count = 1;
}
`
My other class, phonetranslator.cs :
`using System.Text;
using System;
namespace Core
{
public static class PhonewordTranslator
{
public static string ToNumber(string raw)
{
if (string.IsNullOrWhiteSpace(raw))
return "";
else
raw = raw.ToUpperInvariant();
}`
Same question here. Just beginner : (
Try to Clear and Build it again?
I guess it's resource problem
I'm having the exact same problem. This is freaking ridiculous, how am I suppose to learn how to use xamarin if the first tutorial exercise doesn't work!!!!
I get the following error messages:
E:\My Documents\My Documents\Xamarin\Projects\Phoneword\Phoneword\Resources\layout\Main.axml(0,0): Error APT0000: String types not allowed (at 'id' with value ' @+id/TranslateButton'). (APT0000) (Phoneword)
AND:
E:\My Documents\My Documents\Xamarin\Projects\Phoneword\Phoneword\Resources\layout\Main.axml(0,0): Error APT0000: String types not allowed (at 'id' with value ' @+id/CallButton'). (APT0000) (Phoneword)
Builds fine here. What version of Xamarin.Android are you using?
The details are:
Xamarin.Android
Version: 5.1.4 (Trial Edition)
Android SDK: C:\Users\Chris\AppData\Local\Android\android-sdk
Supported Android versions:
4.0.3 (API level 15)
4.4 (API level 19)
5.0 (API level 21)
Java SDK: C:\Program Files (x86)\Java\jdk1.7.0_71
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) Client VM (build 24.71-b01, mixed mode, sharing)
I just updated to a newer version of Xamarin.Andoid (Version: 5.1.5 (Trial Edition)) but the problem persists.
How can such a simple button naming issue cause so much hassle?!
To run Successfully the Demo App, you can just let the default @+Id name !
Same error ...I also beginner....if start having such a hell error...how to learn..
You have this:
android:id=" @+id/CallButton"
And you probably need this:
android:id="@+id/CallButton"
Notice I removed the empty space in front of the @.
Yeah, it has some problem. When solve it ?
Yeah, it has casesam.co.uk some problem. When solve it ?
As @CodeRinse said, for some reasons an extra space is added in the Main.xaml file, make sure that to correct as he points out.
Second issue:
You build your solution and bam: Resource doesn't exist in this context.
Ok, so don't try to go higher and add Android.Resource "in case"...it'd work. It doesn't.
Don't touch this code except for where we are asked to change the Activity Label :
[Activity (Label = "Phone Word", MainLauncher = true, Icon = "@drawable/icon")]
Then scroll down the files in phoneword , you'll find the directory Resources, get inside and compile the file Resource.designer.cs .
Now, if you did like me aka: go all free versions, you'll have a message telliing you that you're missing ..I don't remember the name. You have 3 choices proposed: Purchase the Indie version, Get the not free version of Xamarin Studio, or use the Trial.
I went for the Trial.
Now go back to your namespace phoneword(second "item" from the top in the Solution display window) click on the gear, click on build phoneword and tht's it.
Hope it helped!