簡體   English   中英

Android Studio上的清單合並錯誤

[英]Manifest Merger Error on Android Studio

我基本上是在嘗試從一項活動轉到Google Maps活動。 我將MapsActivity文件添加到清單文件中,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="mahboob.cmec">

    <uses-permission android:name="android.permission.INTERNET" />

    <!--
         The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
         Google Maps Android API v2, but you must specify either coarse or fine
         location permissions for the 'MyLocation' functionality. 
    -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".menu" />
        <activity android:name=".Reference" />
        <activity android:name=".Registration" />
        <activity android:name=".RegistrationComplete" />
        <activity android:name=".electricitybill" />
        <activity android:name=".GasBill" />
        <activity android:name=".BillReport" />
        <activity android:name=".SetTarget" />
        <activity android:name=".EcoReport" />
        <activity android:name=".MapsActivity" />
        <activity android:name=".ManageContract" />
        <activity android:name=".GraphReport" />

        <!--
             The API key for Google Maps-based APIs is defined as a string resource.
             (See the file "res/values/google_maps_api.xml").
             Note that the API key is linked to the encryption key used to sign the APK.
             You need a different API key for each encryption key, including the release key that is used to
             sign the APK for publishing.
             You can define the keys for the debug and release targets in src/debug/ and src/release/. 
        -->
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key" />

        <activity
            android:name=".MapsActivity"
            android:label="@string/title_activity_maps"></activity>
    </application>

</manifest>

運行代碼時,得到以下輸出:

錯誤:任務':app:processDebugManifest'的執行失敗。
>清單合並失敗,並出現多個錯誤,請參閱日志

我不確定是什么問題,我以為我需要將MapsActivity類添加到我完成的清單文件中。

OUTPUT:
Information:Gradle tasks [:app:clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:assembleDebug]
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2340Library
:app:prepareComAndroidSupportAppcompatV72340Library
:app:prepareComAndroidSupportMediarouterV72200Library
:app:prepareComAndroidSupportSupportV42340Library
:app:prepareComAndroidSupportSupportVectorDrawable2340Library
:app:prepareComBasgeekballAwesomeValidation13Library
:app:prepareComGoogleAndroidGmsPlayServices750Library
:app:prepareComGoogleAndroidGmsPlayServicesAds750Library
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics750Library
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing750Library
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite750Library
:app:prepareComGoogleAndroidGmsPlayServicesAppstate750Library
:app:prepareComGoogleAndroidGmsPlayServicesBase750Library
:app:prepareComGoogleAndroidGmsPlayServicesCast750Library
:app:prepareComGoogleAndroidGmsPlayServicesDrive750Library
:app:prepareComGoogleAndroidGmsPlayServicesFitness750Library
:app:prepareComGoogleAndroidGmsPlayServicesGames750Library
:app:prepareComGoogleAndroidGmsPlayServicesGcm750Library
:app:prepareComGoogleAndroidGmsPlayServicesIdentity750Library
:app:prepareComGoogleAndroidGmsPlayServicesLocation750Library
:app:prepareComGoogleAndroidGmsPlayServicesMaps750Library
:app:prepareComGoogleAndroidGmsPlayServicesNearby750Library
:app:prepareComGoogleAndroidGmsPlayServicesPanorama750Library
:app:prepareComGoogleAndroidGmsPlayServicesPlus750Library
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet750Library
:app:prepareComGoogleAndroidGmsPlayServicesWallet750Library
:app:prepareComGoogleAndroidGmsPlayServicesWearable750Library
:app:prepareComMcxiaokeVolleyLibraryAar100Library
:app:prepareComNumetriclabzNumandroidchartsNumandroidcharts103Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
C:\Users\User\Pictures\work\CMEC26\CMEC16\CMEC14\CMEC\app\src\main\AndroidManifest.xml:52:9-54:68 Error:
    Element activity#mahboob.cmec.MapsActivity at AndroidManifest.xml:52:9-54:68 duplicated with element declared at AndroidManifest.xml:36:9-50
C:\Users\User\Pictures\work\CMEC26\CMEC16\CMEC14\CMEC\app\src\main\AndroidManifest.xml Error:
    Validation failed, exiting
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
:app:processDebugManifest FAILED
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
Information:BUILD FAILED
Information:Total time: 54.528 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

首先,您可以嘗試清理項目然后進行構建。 如果問題仍未解決,則可以嘗試第二種選擇。

其次,這是Android開發中的普遍錯誤。 如果找不到錯誤,則必須查看Gradle控制台信息。 但是默認的gradle控制台信息已關閉。 您需要打開它。

  1. 文件 - >設置
  2. 構建,執行,部署->編譯器
  3. --stacktrace --debug >寫入命令行選項

然后,您可以查看gradle控制台。 您將看到更多信息。 您可以在此處檢測錯誤。

清單中有兩個MapsActivity 刪除其中之一。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM