29

I have several manifest errors regarding some attributes . I have not made any changes to the manifest the application generated automatically yet i get several errors. *( I'm using Android Studio 1.2.2)

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

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="22" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.iustinian.girlfriendsolver.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>

-For the xmlns:android attribute i get "URL not registered " -For android versionCode , versionName , allowBackup , label and theme I get "attribute not allowed here "

I took a look at the manifest documentation and couldn't find an answer . For example the allowBackup attribute is placed exactly like the documentation specifies .

Edit: after looking around some more I found that at android:theme "@style/AppTheme" I get a no resource matches the given name . This is the only thing that shows up in the Gradle Build . I have cleaned and rebuilt the project several times .

Iustinian Olaru
  • 1,231
  • 1
  • 13
  • 33
  • 4
    Did you recently switch to Android Studio/Gradle? – Michael Krause Jul 28 '15 at 18:05
  • What IDE are you using? I suggest you try cleaning your project and rebuilding, that will usually solve these sorts of strange errors. If this doesn't work, let me know! – ryguy Jul 28 '15 at 18:16
  • I have just started using Android Studio and playing with android apps . I did not have any previous projects in Eclipse to say that the migration from one to another could have been the problem. – Iustinian Olaru Jul 28 '15 at 19:03
  • 2
    Certain attributes that used to be specified in the manifest are now supposed to be specified in your build.gradle file instead. These include versionCode, versionName, minSdkVersion and targetSdkVersion. If you've already got these in your build.gradle file, you can safely remove them from your manifest. – Michael Krause Jul 28 '15 at 19:46
  • That solved the "attribute not allowed here" error . Now I have just the @style/AppTheme problem now . Thank you. – Iustinian Olaru Jul 28 '15 at 22:17
  • Also I noticed that although the attributes Michael Krause specified are indeed not in the normal AndroidManifest.xml , when I try to run the app the they still apear as being put in the debug/AndroidManifest.xml – Iustinian Olaru Jul 28 '15 at 22:23

12 Answers12

74

Just Close your manifest file and reopen it. It worked for me.

rajlaxmi_jagdale
  • 1,370
  • 15
  • 16
13

In my case, closing the AndroidManifest.xml AND choosing File > Invalidate Caches / Restart solved the issue.

Not sure why I had to do the last step as well but it sorted out all those errors for me.

lundzern
  • 417
  • 3
  • 11
10

Close AndroidManifest — File — Sync Project with Gradle Files. It helped.

P.S. A few months later I met this problem again — googled — found this answer and it didn't help! :D But this time I removed the Android Studio and installed the beta version. It helped.

Anna
  • 532
  • 4
  • 14
5

In Android Studio just close the Manifest file and open it again. It will solve the issue. By the way Studio gives too many stupid errors like this.

Hammad Khan
  • 157
  • 2
  • 13
4

For your "attribute not allowed here" problem, versionCode, versionName and allowBackup have to be placed in the build.gradle file and not in the Android Manifest. That should solve the problem.

Secondly, for your "@style/AppTheme no resource matches the given name" problem, you will have to check your styles.xml file and make sure that a style with the name AppTheme exists over there.

Hope this helps you or anyone who views this answer.

3

This happens when manifest not correctly "recognized" by AndroidStudio: it is correct location file app/src/main/AndroidManifest.xml, but not in synthetic AS Android/app/manifests tree left-view.

Just close the project + remove from (welcome)list + re-import_project (Gradle, Eclipse ADT, etc).

ltlDroid
  • 31
  • 4
3

In Android Studio -> File -> Syncing Project with Gradle Files, helped me resolve the issue.

Ajay Deepak
  • 471
  • 5
  • 9
2

Close the andorid studio and open the AndroidManifest.xml from the application folder in any of the local editor for e.g., Notepad,notepad++,sublime etc. Make change and save the manifest file. Now open the androdistudio. Your problem will be solve.

Rutvik
  • 137
  • 1
  • 1
  • 9
1

Most Probably, you are modifying the wrong Manifest.xml. When you attempt to run your code, it creates temporary files which might be what you are editing.

amustapha
  • 416
  • 3
  • 12
0

Just open your AndroidManifest.xml file in another editor like notepad++ and apply some changes ,then save it. that might work as a trick!

AmiNadimi
  • 5,129
  • 3
  • 39
  • 55
0

Simple thing is copy paste backup manifest.xml on the project or save code on notepad and saveas with same manifest.xml and override on old manifest.xml

impathuri
  • 574
  • 6
  • 21
0

When you modify certain data in AndroidManifest, it will show an error when you launch the program, and it will also open the DebugAndroidManifest file and show errors.

  1. Step 1.close the Debug AndroidManifest (It will open when you run the code)
  2. Step 2. re run the AndroidManifest
Rasathurai Karan
  • 673
  • 5
  • 16