permission.ACCESS_MOCK_LOCATION红线..或Manifest合并失败,出现多个错误

时间:2015-11-03 07:02:04

标签: android android-studio

我是初学者,我使用的是Android Studio。一个问题一直困扰着我。

继续显示错误消息

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

1 个答案:

答案 0 :(得分:1)

我认为问题就像错误信息所描述的那样:

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

在您的应用程序标记中,您没有为“value”-tag:

设置replacement-attribute
<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">

由于我不知道application-tag中的“android:value”-tag,我建议更改工具:replace-node:

    tools:replace="icon,label,theme"

有关清单合并的更多信息,请访问: http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger