Salman Khalid
Salman Khalid

Reputation: 593

The <activity> element must be a direct child of the <application> element In Library Manifest

I am trying to download and run https://github.com/siwangqishiq/ImageEditor-Android application. It is giving error

Android resource linking failed
C:\Users\salman\Desktop\work\Facemook\ImageEditor-Android-master\demo\build\intermediates\merged_manifests\debug\AndroidManifest.xml:20: error: unexpected element <activity> found in <manifest>.

When I opened file at

C:\Users\salman\Desktop\work\Facemook\ImageEditor-Android-master\demo\build\intermediates\merged_manifests\debug\AndroidManifest.xml

then file's contents are

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

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="28" />

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />

    <uses-feature
        android:name="android.hardware.camera"
        android:required="true" />

    <!-- 图片编辑Activity -->
    <activity android:name="com.xinlan.imageeditlibrary.editimage.EditImageActivity" >
    </activity>

    <application
        android:allowBackup="true"
        android:appComponentFactory="android.support.v4.app.CoreComponentFactory"
        android:debuggable="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:testOnly="true"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
        <activity android:name="com.xinlan.imageeditandroid.MainActivity" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <!-- <activity android:name=".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> -->


        <!-- <activity -->
        <!-- android:name=".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> -->


        <!-- &lt;!&ndash;选择相册图片Activity&ndash;&gt; -->
        <!-- <activity -->
        <!-- android:name="com.xinlan.imageeditlibrary.picchooser.SelectPictureActivity" -->
        <!-- android:screenOrientation="portrait"> -->
        <!-- </activity> -->


        <!-- &lt;!&ndash;图片编辑Activity&ndash;&gt; -->
        <!-- <activity -->
        <!-- android:name="com.xinlan.imageeditlibrary.editimage.EditImageActivity" -->
        <!-- android:screenOrientation="portrait" -->
        <!-- android:windowSoftInputMode="adjustPan"> -->
        <!-- </activity> -->

    </application>

</manifest>

As you can see this file contains <activity> outside of <application> which is causing error, but this file is merged (created by Android Studio after merging all manifest files) so I cannot (or should not) edit it. Now contents of manifest of library module (again library module) are given below

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.xinlan.imageeditlibrary" >
    <!--图片编辑Activity-->
    <activity android:name="com.xinlan.imageeditlibrary.editimage.EditImageActivity">
    </activity>
</manifest>

Here you can see real problem. <activity> is outside of any <application> block. As mentioned, this manifest is of library I cannot surround with <application>. How to solve it? The <uses-permission> element must be a direct child of the <manifest> root element The <activity> element must be a direct child of the <application> element error Splash Screen Activity - The element must be a direct child of the element [WrongManifestParent] These all refer to main module manifest file, not library module manifest file.

Upvotes: 1

Views: 195

Answers (1)

Salman Khalid
Salman Khalid

Reputation: 593

Solved, just surround with . i.e.

<application>
<activity></activity>
</application>

Upvotes: 2

Related Questions