<activity>元素必须是Library Manifest中<application>元素的直接子元素

时间:2019-06-14 14:41:59

标签: android android-activity android-manifest manifest

我正在尝试下载并运行https://github.com/siwangqishiq/ImageEditor-Android应用程序。它给出了错误

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>.

当我在打开文件时

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

然后文件的内容是

<?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>

您可以看到此文件包含<activity>之外的<application>,这会导致错误,但是此文件已被合并(合并所有清单文件后由Android Studio创建),因此我无法(或不应该) )进行编辑。现在,在下面给出库模块 (再次是库模块)的清单内容

<?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>

在这里您可以看到真正的问题。 <activity>在任何<application>块之外。如前所述,此清单属于我无法用<application>包围的库。怎么解决呢? 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] 这些都是指主模块清单文件,而不是库模块清单文件。

1 个答案:

答案 0 :(得分:1)

已解决,仅用包围。即

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