Unable to get provider com.google.android.gms.measurement.AppMeasurementContentProvider
<p>I tried to Set up GCM in my project as given in <a href="https://developers.google.com/cloud-messaging/android/client" rel="nofollow noreferrer">Set up a GCM Client App on Android</a> and to <a href="https://developers.google.com/cloud-messaging/android/client#play-services" rel="nofollow noreferrer">Set Up Google Play Services</a> added dependency </p>

<pre><code>  compile "com.google.android.gms:play-services-gcm:8.4.0"
</code></pre>

<p>to the dependency section of my application's <strong>build.gradle</strong> file.</p>

<p>And In the root gradle file add classpath as given in sample project(Sample cloned from <code>$ git clone https://github.com/googlesamples/google-services.git</code>) as</p>

<pre><code>dependencies {
    classpath 'com.android.tools.build:gradle:2.0.0-beta6'
    classpath 'com.google.gms:google-services:2.0.0-beta6'
}
</code></pre>

<p>It's building fine, but it crashes on launch with the following stack trace :</p>

<blockquote>
  <p>java.lang.RuntimeException: Unable to get provider
  com.google.android.gms.measurement.AppMeasurementContentProvider:
  java.lang.NullPointerException: null reference
                                                                     at android.app.ActivityThread.installProvider(ActivityThread.java:5156)
                                                                     at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
                                                                     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
                                                                     at android.app.ActivityThread.-wrap1(ActivityThread.java)
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                     at android.os.Looper.loop(Looper.java:148)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                  Caused by: java.lang.NullPointerException: null reference
                                                                     at com.google.android.gms.common.internal.zzx.zzy(Unknown Source)
                                                                     at com.google.android.gms.measurement.internal.zzt.zzaU(Unknown Source)
                                                                     at com.google.android.gms.measurement.AppMeasurementContentProvider.onCreate(Unknown
  Source)
                                                                     at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
                                                                     at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
                                                                     at android.app.ActivityThread.installProvider(ActivityThread.java:5153)
                                                                     at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748) 
                                                                     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688) 
                                                                     at android.app.ActivityThread.-wrap1(ActivityThread.java) 
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
                                                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                     at android.os.Looper.loop(Looper.java:148) 
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)</p>
</blockquote>

<p>Also tried related stack questions:</p>

<ol>
<li><a href="https://stackoverflow.com/questions/33571555/updating-play-services-from-8-1-to-8-3-with-proguard-enabled">Updating Play services from 8.1 to 8.3 with Proguard enabled</a></li>
<li><a href="https://stackoverflow.com/questions/33196015/error-on-some-devices-couldnt-find-class-com-google-android-gms-measurement">Error on some devices - couldn't find class
'com.google.android.gms.measurement.internal.zzz'</a></li>
</ol>

<p>As answered in 1st link tried classpath</p>

<pre><code>classpath 'com.google.gms:google-services:1.5.0'
</code></pre>

<p>and as answered in 2nd link,tried Multidex also with no success.</p>

<p>Also tried for <strong>Application Measurement</strong>  adding </p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;resources&gt;
   &lt;integer name="google_app_measurement_enable"&gt;0&lt;/integer&gt;
&lt;/resources&gt;
</code></pre>

<p>as suggested in <a href="https://developers.google.com/android/guides/releases#september_2015_-_v81" rel="nofollow noreferrer">Play Services Release notes</a>.</p>

<p>Note : sample code running.</p>

<hr>

<p><strong>Update :</strong></p>

<p>Interesting thing is that same error even if I add only dependency</p>

<pre><code>  compile "com.google.android.gms:play-services-gcm:8.4.0"
</code></pre>

<p>in my app gradle file(Note : Only one line added in Existing project).And there is no error after adding </p>

<pre><code>compile "com.google.android.gms:play-services-gcm:8.1.0"
</code></pre>

<p>i.e. the token works on <strong>8.1.0</strong>.Interesting,isn't?</p>