Android Studio: Error in Layout Files - Header expected

≡放荡痞女 提交于 2019-12-11 10:58:19

问题


Every time I create a TextView and set a text to it, the AS-Editor would throw an error: "Header expected - Manifest file doesn't end with a final newline"

The code:

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="eu.myurl.myproject"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="eu.myurl.myproject.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

The error is already there when creating a new project. Hardcoded Strings also dont work.

Why is this happening and what can be done about?

Im using Android Studio 0.2.7 with JRE: 1.7.0_21


回答1:


Click on the word with the red line (that causes the mentioned error) Click Alt+Enter and choose

Un-inject Language/Reference

That's it! At least this worked for me on the same error



来源:https://stackoverflow.com/questions/18758574/android-studio-error-in-layout-files-header-expected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!