AAPT: error: unexpected element <uses-permission> found in <manifest><application>

Vijay picture Vijay · May 26, 2019 · Viewed 12.4k times · Source

I am trying to create an android app for watchduino2.. When i follow the provided steps i encounter the error

AAPT: error: unexpected element <uses-permission> found in <manifest><application>

Can somebody explain this problem? And also help me to resolve it as well.

Answer

CommonsWare picture CommonsWare · May 26, 2019

<uses-permission> needs to be a child of the root <manifest> element. You have it as a child of the <application> element. So, move the <uses-permission> element.

So, you have something like:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="net.whatever">
    <application android:icon="@drawable/icon"
                 android:debuggable="true"
                 android:label="@string/app_name">
        <uses-permission android:name="android.permission.INTERNET"/>
      <!-- other stuff here -->
    </application>
</manifest>

It needs to be more like:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="net.whatever">
    <uses-permission android:name="android.permission.INTERNET"/>
    <application android:icon="@drawable/icon"
                 android:debuggable="true"
                 android:label="@string/app_name">
      <!-- other stuff here -->
    </application>
</manifest>