Reputation: 53
I'm trying to implement GCM in my app for the first time, so I've followed the steps and there's an error that make my app doesn't get the token for registration in my sv.
It says:
09-30 23:05:52.196 31461-31514/com.comgonzalovillarbaribus E/GMPM﹕ getGoogleAppId failed with status: 10
09-30 23:05:52.200 31461-31514/com.comgonzalovillarbaribus E/GMPM﹕ Uploading is not possible. App measurement disabled
I don't know what the problem is, my manifest is correct, my GCM_SENDER_ID
is ok.
Here is where I ask for my token:
// Set GCM
if (checkPlayServices()) {
InstanceID instanceID = InstanceID.getInstance(this);
String token = null;
try {
token = instanceID.getToken(Constants.GCM_SENDER_ID, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
sendRegistrationToServer(token);
} catch (IOException e) {
e.printStackTrace();
}
}
...
private void sendRegistrationToServer(String token) {
HomeActivity.newRegID=token;
//WebServerRegistrationTask webServer=new WebServerRegistrationTask();
//webServer.execute();
// Create params
RequestParams params = new RequestParams();
params.add("regID",token);
// Doing the req
AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
asyncHttpClient.post(Constants.WEB_SERVER_URL, params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
String key = responseBody.toString();
Log.e("key", key);
}
@Override
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
Log.e("error", "conexion");
}
});
}
This is my updated manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.comgonzalovillarbaribus" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.comgonzalovillarbaribus.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.comgonzalovillarbaribus.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".HomeActivity"
android:label="@string/title_activity_home" >
</activity>
<activity
android:name=".ActivityHorariosLinea"
android:label="@string/title_activity_activity_horarios_linea">
</activity>
<activity
android:name=".ActivityHorariosParada"
android:label="@string/title_activity_activity_horarios_parada" >
</activity>
<activity
android:name=".ActivityListaTrabajos"
android:label="@string/title_activity_activity_lista_trabajos" >
</activity>
<receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.comgonzalovillarbaribus"/>
</intent-filter>
</receiver>
<service
android:name=".GCM.MyGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name=".GCM.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<service
android:name=".GCM.RegistrationIntentService"
android:exported="false">
</service>
</application>
</manifest>
I already have the api enabled in the console. My app is not in the play store.
Upvotes: 3
Views: 7387
Reputation: 12861
In your project AndroidManifest.xml
you have given following permission for package com.example.gcm
which does not exist
<permission android:name="com.example.gcm.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />
Your application package is com.comgonzalovillarbaribus
so try this line:
<permission android:name="com.comgonzalovillarbaribus.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.comgonzalovillarbaribus.permission.C2D_MESSAGE" />
Remove this com.example.gcm
package name from your AndroidManifest.xml
EDIT:
Use this also instead you have mentioned in comment.
<receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.comgonzalovillarbaribus"/>
</intent-filter>
</receiver>
Upvotes: 0
Reputation: 1800
I got same error, after recheck, i forgot to do 2 steps below:
Add the dependency to your project-level build.gradle:
classpath 'com.google.gms:google-services:1.5.0-beta2'
Add the plugin to your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
Upvotes: 1