android – Manifest element must be declared-ThrowExceptions

Exception or error:

This error occurs in ic_launcher.xml file that located in mipmap-anydpi-v26 directory and I can not solve it even I tried to change its location.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.robpercival.listviewdemo">

<application android:allowBackup="true"
             android:icon="@mipmap/ic_launcher"/>


</manifest >

similar problems occur with RelativeLayout and menu elements and I solve them by deleting ic_launcher files from drawable directory and creating new files in menu and layout directories. I am not sure but maybe these problems happen when android studio version is updated to 3.5.

How to solve:

Problem is you delete ‘ic_launcher’ file form drawable folder to solve RelativeLayout menu element problem,

but this file is linked in /mipmap/ic_launcher/ic_launcher.xml and /mipmap/ic_launcher_round/ic_launcher_round.xml file in mipmap folder.

<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
   <background android:drawable="@drawable/ic_launcher_background" />
   <foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

just delete 2 file

/mipmap/ic_launcher/ic_launcher.xml(anydpi-26)

/mipmap/ic_launcher_round/ic_launcher_round.xml(anydpi-26)

Edit

Or,

Copy ic_launcher_round(xxxhdpi) to drawable folder.

and edit

/mipmap/ic_launcher/ic_launcher.xml(anydpi-26)

/mipmap/ic_launcher_round/ic_launcher_round.xml(anydpi-26)

like this

<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
  <background android:drawable="@drawable/ic_launcher_round" />
  <foreground android:drawable="@drawable/ic_launcher_round" />
</adaptive-icon>

Leave a Reply

Your email address will not be published. Required fields are marked *