android - 什么是 AppMeasurementService 以及为什么 Android Studio 将此服务添加到我的应用程序中?

标签 android

我最近开始使用 Android Studio 设计一个应用程序,Android Studio 似乎在我不知情的情况下向我的 list 中添加了一些东西。

例如它添加了一个服务:
com.google.android.gms.measurement.AppMeasurementService

我不知道它为什么在那里。并且它还添加了权限,例如:

com.google.android.c2dmpermission.RECEIVE
android.permission.USE_CREDENTIALS

这会增加我的应用程序的大小和内存消耗,所以我想摆脱它,但我还没有弄清楚如何。

以为它可能在 Android 的“项目结构”菜单项中,但找不到任何地方将其关闭。所有开发人员服务都已关闭(尽管 Analytics 似乎默认已激活,但我已将其关闭)。

如果有任何关于如何删除所有这些自动添加的内容的指示,我将不胜感激?

谢谢

编辑: 进一步调查后发现我的AndrodManifest.xml在

  build\intermediates\manifests\full\release 

目录包含很多附加信息:

    <!-- Include the AdActivity and InAppPurchaseActivity configChanges and themes. -->
    <activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
        android:theme="@android:style/Theme.Translucent" />
    <activity
        android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity"
        android:theme="@style/Theme.IAPTheme" />

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <provider
        android:name="com.google.android.gms.measurement.AppMeasurementContentProvider"
        android:authorities="net.stefano.stefanoface.google_measurement_service"
        android:exported="false" />

    <receiver
        android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
        android:enabled="true" >
        <intent-filter>
            <action android:name="com.google.android.gms.measurement.UPLOAD" />
        </intent-filter>
    </receiver>

    <service
        android:name="com.google.android.gms.measurement.AppMeasurementService"
        android:enabled="true"
        android:exported="false" />

    <meta-data
        android:name="com.google.android.wearable.beta.app"
        android:resource="@xml/android_wear_micro_apk" />

AdActivity 和 InAppPurchaseActivity 似乎是自动添加的,但在“项目结构”中所有开发人员服务都已关闭。怎么会有这个?

build.gradle 文件:

     compileSdkVersion 22
     buildToolsVersion "22.0.1"
    defaultConfig {
        applicationId "net.stefano.stefanoface"
        minSdkVersion 18
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    wearApp project(':wear')
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.android.support:design:22.2.1'
    compile 'com.google.android.gms:play-services-base:7.5.0'
}

是的,我正在开发一个 Wear 应用,所以我确实需要访问 Google Play 服务,但只需要 Wear 部分。

谢谢

最佳答案

进入模块的 build.gradle 文件(例如,app/build.gradle)。查看 dependencies 闭包。根据您的症状,您应该有 1+ 个条目,其中至少一个来自 Play Services SDK。确定那里有什么,并删除不需要的项目。

另见 this SO answerthis blog post .

关于android - 什么是 AppMeasurementService 以及为什么 Android Studio 将此服务添加到我的应用程序中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33366846/

相关文章:

android - ACTION_MANAGE_OVERLAY_PERMISSION 未重定向到 Api 30 中的应用页面

javascript - 从 Android 浏览器打开 Instagram

android - 在 Facebook 墙上发布内容而不在 Android 上显示对话框

php - Paypal IPN 响应未进入 Android 移动浏览器

java - 前台服务: how to handle user enable/disable

android - 什么是最可靠的安卓时钟?

android - 通过蓝牙检测附近的另一个安卓设备

java - 获取 TextView 的高度

android - 我可以使用同一个 keystore 文件来签署两个不同的应用程序吗?

android - 隐藏通知栏