简体   繁体   English

“标签 <Activity > 属性名称包含无效字符&#39;&#39;。 “Android Manifest

[英]“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.

相关问题 错误:(15)标签 <uses-permission> 属性名称包含无效字符&#39;&#39;.Android清单 - Error:(15) Tag <uses-permission> attribute name has invalid character ' '.Android Manifest 标签 <manifest> 属性包中包含无效字符&#39;; “ - Tag <manifest> attribute package has invalid character '; ' 标签<uses-permission>属性名称包含无效字符'' - Tag <uses-permission> attribute name has invalid character ' ' 格式错误的清单-标签 <activity> 缺少必需的属性名称 - Malformed Manifest - Tag <activity> missing required attribute name 错误:(20)标签 <uses-permission> 属性名称包含无效字符&#39;&#39; - Error:(20) Tag <uses-permission> attribute name has invalid character ' ' 我的Android xml文件中出现AAPt错误:标记 <category> 属性包含无效字符 - I have AAPt error on my Android xml file: Tag <category> attribute has invalid character 的清单名称属性 <service> 标签 - Manifest name attribute of <service> tag Android清单属性“名称”文件错误 - Android Manifest Attribute “name” File Error 当 Android Studio 中没有活动标签时,如何在清单中添加导出的标签? - How to add exported label in manifest when there is no activity tag in Android Studio? Android-访问清单中的提供者标签并更改其属性值 - Android - Accessing provider tag in manifest and change it's attribute value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM