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.
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.
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.
The solution I found is to move the
NotificationListenerService
to it's ownprocess
. 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 theBIND_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 yourManifest.xml
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
Make sure you use
context
and notLocalBroadcastManager
, cause it doesn't work with processes.Exclude firebase-core libraries in your gradle file. I have faced the same issue.
}
For more details about firebase libraries just go through following link
http://blog.safedk.com/technology/mobile-sdks-firebase-or-play-services/
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
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.