[英]“Tag <Activity > attribute name has invalid character ' '. ” Android Manifest
I am getting the error "Tag attribute name has invalid character ' '. " in the Android Manifest, while there is no obviously invalid character. 我在Android Manifest中收到错误“Tag属性名称有无效字符'。”,而没有明显无效的字符。 Here is the code:
这是代码:
<activity
android:name="Quiz 31"
android:configChanges="orientation|keyboardHidden"
android:label="Quiz 31"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="com.SoulSlayerAbad.AMQ.QUIZ31" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
As you can see, no ' ' character in the code. 如您所见,代码中没有''字符。 Does anyone know why this is happening?
有谁知道为什么会这样? One thing to note is that I generated this piece of code using a few lines of Java run inside of Eclipse console.
需要注意的一点是,我使用Eclipse控制台内部运行的几行Java生成了这段代码。 The code for that is:
代码是:
int Begin = 0, End = 0;
Scanner sc = new Scanner(System.in);
String Text = " <activity "+
"android:name=\"Quiz "+Begin+"\" "+
"android:configChanges=\"orientation|keyboardHidden\" "+
"android:label=\"Quiz "+Begin+"\" "+
"android:screenOrientation=\"portrait\" "+
"android:theme=\"@android:style/Theme.NoTitleBar\" > "+
"<intent-filter> "+
"<action android:name=\"com.SoulSlayerAbad.AMQ.QUIZ"+Begin+"\" /> "+
"<category android:name=\"android.intent.category.DEFAULT\" /> "+
"</intent-filter> "+
"</activity> ";
System.out.println("Begining:");
Begin = sc.nextInt();
System.out.println("End At:");
End = sc.nextInt();
while(Begin <= End){
System.out.println(Text);
Begin++;
}
android:name
is supposed to have reference of your class path which represents the activity. android:name
应该引用代表该活动的类路径。 It must not contain any special characters or spaces. 它不得包含任何特殊字符或空格。
For example: 例如:
android:name="com.json.test.MainActivity"
Here, MainActivity
is the class file which extends an Activity
. 这里,
MainActivity
是扩展Activity
的类文件。
Your name attribute should contain your activity class: 您的name属性应包含您的活动类:
android:name The name of the class that implements the activity, a subclass of Activity.
android:name实现活动的类的名称,Activity的子类。 The attribute value should be a fully qualified class name (such as, "com.example.project.ExtracurricularActivity")
属性值应该是完全限定的类名(例如,“com.example.project.ExtracurricularActivity”)
android:name
不能包含空格,它是类的名称。
Well for starters you're missing an escaped quote; 对于初学者来说,你错过了一个逃脱的报价; are you sure that code compiles?
你确定代码编译好吗?
"<action android:name=\"com.SoulSlayerAbad.AMQ.QUIZ"+Begin+"\" /> "+
Slash missing before the double quote just before +Begin
. 在
+Begin
之前的双引号之前删除了缺失。
Secondly, if you actually aren't missing that slash, but when you pasted it here it made it look like it, perhaps an odd control character made it into that line. 其次,如果你实际上并没有错过那个斜线,但是当你把它粘贴在这里时,它看起来就像它,也许是一个奇怪的控制角色使它成为那条线。
Try deleting that line and retyping it from scratch. 尝试删除该行并从头开始重新输入。
You could also open your manifest file in a hex editor and verify that no strange non-printable characters are mixed in. 您还可以在十六进制编辑器中打开清单文件,并确认没有混合奇怪的不可打印字符。
your android:name
does not contain white spaces or special characters. 你的
android:name
不包含空格或特殊字符。 for example android name should be like this 例如,android名称应该是这样的
<activity
android:name="com.example.users.projectname.MainActivity">
</activity>
In additional package
is also needed to be named in English alphabet other case AndroidManifest gives similar error. 在额外的
package
中也需要用英文字母命名其他情况AndroidManifest给出类似的错误。 That I experienced 我经历过的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.