2015-11-03 195 views
2

我是初學者,我使用Android Studio的失敗。一個問題一直困擾着我。permission.ACCESS_MOCK_LOCATION紅線..或清單合併多個錯誤

它不斷顯示錯誤消息

Element uses-permission#com.google.android.providers.gsf.permission.READ_GSERVICES at AndroidManifest.xml:46:2-95 duplicated with element declared at AndroidManifest.xml:35:5-98 

Element uses-permission#android.permission.ACCESS_COARSE_LOCATION at AndroidManifest.xml:47:2-78 duplicated with element declared at AndroidManifest.xml:22:5-81 

Element uses-permission#android.permission.ACCESS_FINE_LOCATION at AndroidManifest.xml:48:2-76 duplicated with element declared at AndroidManifest.xml:23:5-79 

tools:replace specified at line:67 for attribute tools:value, but no new value specified 

Element meta-data#com.google.android.gms.version at AndroidManifest.xml:85:9-87:39 duplicated with element declared at AndroidManifest.xml:81:10-83:69 

Validation failed, exiting 

Manifest merger failed with multiple errors 

也紅線

uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" 

Mock locations should only be requested in a test or debug-specific manifest file (typically src/debug/AndroidManifest.xml) less... (Ctrl+F1) 
Using a mock location provider (by requiring the permission android.permission.ACCESS_MOCK_LOCATION) should only be done in debug builds (or from tests). In Gradle projects, that means you should only request this permission in a test or debug source set specific manifest file. To fix this, create a new manifest file in the debug folder and move the <uses-permission> element there. A typical path to a debug manifest override file in a Gradle project is src/debug/AndroidManifest.xml. 

我已經試過:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    package="com.Hi.Hello"> 



<application 
     android:name="com.Hi.Hello.app.App" 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:largeHeap="true" 
     android:hardwareAccelerated="true" 
     android:theme="@style/AppBaseTheme" 
     tools:replace="value,icon,label,theme"> 

,但我沒能解決。許可問題和清單合併失敗,有關關於幫助的多個錯誤!

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.1" 

    defaultConfig { 
     applicationId "com.Hi.Hello" 
     minSdkVersion 14 
     targetSdkVersion 23 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 
     } 
    } 
} 

dependencies { 
    compile project(':bFAB') 
    compile project(':bPhotoView') 
    compile project(':bSlidingLayer') 
    compile project(':bSlidingMenu') 
    compile project(':bUniversalImageLoader') 
    compile project(':bUtils') 
    compile project(':bTwoWayView') 
    compile project(':facebookSDK') 
    compile project(':kakaoSDK') 
    compile files('libs/httpclient-4.2.3.jar') 
    compile files('libs/httpclient-cache-4.2.3.jar') 
    compile files('libs/httpcore-4.2.2.jar') 
    compile files('libs/httpmime-4.2.3.jar') 
    compile files('libs/jsoup-1.7.3.jar') 
    compile files('libs/gcm.jar') 
    compile 'com.google.android.gms:play-services:8.1.0' 
    compile 'com.google.code.gson:gson:2.2.2' 
    compile 'com.android.support:appcompat-v7:23.1.0' 
    compile 'com.google.android.gms:play-services-ads:8.1.0' 
    compile 'com.google.android.gms:play-services-identity:8.1.0' 
    compile 'com.google.gcm:gcm-server:1.0.0' 
} 

enter image description here

enter image description here

+0

您有另一個manifest.xml(可能從一個依賴項目)聲明這些相同的權限並導致這些錯誤。 –

+0

我會查找它謝謝 – kimtaehun

+1

您是否已經在某處定義了權限ACCESS_MOCK_LOCATION?您是否嘗試將權限僅限於Debug-Buildtype的Android清單中?這是來自錯誤描述的建議。 – Christopher

回答

1

我認爲這個問題是類似的錯誤信息說明:

tools:replace specified at line:67 for attribute tools:value, but no new value specified 

在你的應用程序標籤不設置了一個替代屬性「value」-tag:

<application 
    android:name="com.Hi.Hello.app.App" 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:largeHeap="true" 
    android:hardwareAccelerated="true" 
    android:theme="@style/AppBaseTheme" 
    tools:replace="value,icon,label,theme"> 

由於我不知道的:在應用程序標籤的「Android值」 - 標籤,我會建議修改工具:更換節點:有關清單合併

tools:replace="icon,label,theme" 

更多的信息可能是在這裏找到: http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger

+0

以前沒有「價值」 ..但連續錯誤味精...所以增加價值 – kimtaehun

+0

謝謝你讓我知道 – kimtaehun