15

I have encountered an issue that GooglePlayServices app is using my application process for their service and also showing the processes count as 2.
I have attached the screenshot for the same. I have no idea why it is happening.
It is taking more memory compare to my app process.


Someone please can help me on this.

enter image description here


Showing two processes hereenter image description here

Noundla Sandeep
  • 3,334
  • 5
  • 29
  • 56

7 Answers7

2

I encountered this today after I added gcm to my app and can't figure out what exactly is the use of this MeasurementBrokerService. The only thing I found was this comment:

"I also had it and guess it is related to notification listener since it appears that Preventing macrodroid's notifications access make it stop. ( hope i m clear, my english is only remaining of school times...)"

from here

Guy S
  • 1,424
  • 1
  • 15
  • 34
  • 2
    I'm the guy who makes MacroDroid (your quote is from my forum) and I still haven't got to the bottom of what exactly causes this to appear. All I know is that when I watch the memory usage of the running app, I see it pop up now and again and it shows memory usage of 70MB. Of course some users see this added to the apps usage and then complain about the amount of memory. There is still very little info about regarding this... – JamieH Feb 22 '16 at 21:24
  • 3
    @JamieH. I am also unable to find the reason for it. The previous version of the build of my app is not showing as above, but the latest version shows the gms service under the process of my app`s services in running apps as shown in above screen shots. The major changes in the latest version are compileSdkVersion from 22 to 23 and the support libs(v4,v7 and design) from 22 to 23. The google play services version is same. – binaryKarmic Feb 23 '16 at 10:32
  • anyone find a cause? It has started in my app recently. – Kushan Feb 10 '17 at 10:18
2

We've seen this service show up as well. The issue turned out to be using Google Analytics along with a NotificationListenerService.

For some reasons these two things didn't play well together and caused MeasurementBrokerService to be always running, and consuming a significant amount of memory.

The solution for us was to remove Google Analytics for an alternative analytics solution.

David Zhao
  • 21
  • 1
2

People who still check this thread for an answer, I have found a solution and posted an answer at:

what is Google Play services MeasurementBrokerService and how to stop it?

I checked that somehow still google AppMeasurement service was running on my device.

I have resorted to using the following approach:

The following stops data collection by firebase.

https://firebase.google.com/support/guides/disable-analytics tells us the following approach

<meta-data android:name="firebase_analytics_collection_deactivated" android:value="true" />

This alone still can't stop the appMeasurement from initializing.

The second step that has solved is adding the following to the app level gradle file:

configurations {
    all*.exclude group: 'com.google.firebase', module: 'firebase-core'
}

This basically removes all the code that firebase analytics uses.

In case it still doesn't work, make sure that the gradle does not include broad play service dependency

eg: compile

'com.google.android.gms:play-services-location:10.0.1'

instead of

'com.google.android.gms:play-services:10.0.1'

Worst case and i have not tested this as the above solved it for me is:

https://developers.google.com/analytics/devguides/collection/android/v4/advanced

Google should really stop putting unwanted things without the dev's permission IMHO. Hope this helps someone

Community
  • 1
  • 1
Kushan
  • 5,855
  • 3
  • 31
  • 45
2

Exclude firebase-core libraries in your gradle file. I have faced the same issue.

configurations {
all*.exclude group: 'com.google.firebase', module: 'firebase-core'

}

For more details about firebase libraries just go through following link

http://blog.safedk.com/technology/mobile-sdks-firebase-or-play-services/

Kavita Patil
  • 1,784
  • 1
  • 17
  • 30
2

The solution I found is to move the NotificationListenerService to it's own process. While having Google Play Services on another.

Background

First of all it is already a good decision to separate the NotificationListenerService, because this thing is running constantly after user grants the BIND_NOTIFICATION_LISTENER_SERVICE permission.

Basically unless declared otherwise, your app is going to use one process. This means that inside the "Running Services" tab in addition to all notification data stored in the NotificationListenerService you are going to see all your garbage that is yet to be collected by GC.

How to

In order to run a service in it's own process you need to add the android:process attribute in your Manifest.xml

<service android:name="com.mypackage.services.NotificationService"
android:label="@string/app_name"
android:process=":myawesomeprocess"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">

Things to remember

You can't communicate between processes in a regular way! You won't be able to access another Class from a Service that resides in it's own process. The only solution is to use Broadcasts

//Send
Intent intent = new Intent("com.mypackage.myaction");
context.sendBroadcast(intent);

//Receive
registerReceiver(broadcastReceiver, new IntentFilter("com.mypackage.myaction"));

BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action!=null&&action.equals("com.mypackage.myaction")) {
            //
        }
    }
};

//Don't forget to unregister
unregisterReceiver(broadcastReceiver);

Make sure you use context and not LocalBroadcastManager, cause it doesn't work with processes.

Fossor
  • 268
  • 1
  • 7
  • 21
0

This could be related to your Google Analytics integration in your app. Remove the Google Analytics references from your Java code, project level and App level gradle files. This leak is happening only in the latest Google Analytics versions. You can integrate the old Google Play Services versions like 7.3.0 which doesn't have this issue to fix this leak.

venkat
  • 517
  • 1
  • 8
  • 29
0

I could manage to solve the issue by setting back Gradle version to 2.0.0 from 2.3.2. Because of this I had to set Gradle wraper to 2.14.1 from 3.3.

Also I set back to buildToolsVersion '23.0.1' from buildToolsVersion '25.0.2'.

By compiling the project like this, probably made many changes in the build environment, because when I changed everything back to the original version the problem disappeared, no MeasurementBrokerService is running anymore.

plexnor
  • 21
  • 1
  • 5