oney / react-native-gcm-android

GCM for React Native Android
MIT License
172 stars 76 forks source link

Crash on registration #33

Closed jlugner closed 8 years ago

jlugner commented 8 years ago

I'm getting the following exception when trying to add an event lister for 'register' events. Any ideas?

FATAL EXCEPTION: IntentService[GcmRegistrationService] at com.oney.gcm.GcmRegistrationService.onHandleIntent(GcmRegistrationService.java:30)
Process: com.myapp, PID: 23592
android.content.res.Resources$NotFoundException: String resource ID #0x0
 at android.content.res.Resources.getText(Resources.java:321)
 at android.content.res.Resources.getString(Resources.java:407)
 at android.content.Context.getString(Context.java:377)
 at com.oney.gcm.GcmRegistrationService.onHandleIntent(GcmRegistrationService.java:31)
 at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:135)
 at android.os.HandlerThread.run(HandlerThread.java:61)
Force finishing activity 1 com.myapp/.MainActivity
Tried to remove non-existent frame callback
oney commented 8 years ago

Do you have android/app/google-services.json file?

jlugner commented 8 years ago

Yes. I'm not sure how to validate that it's correct, but it is there.

oney commented 8 years ago

Please try this solution. Or, delete android/build and android/app/build directories and re-run. The last solution is finding project_number in android/app/google-services.json(eg 309660514018 in TestGcm project), and hard code the projectNumber in line 30 of node_modules/react-native-gcm-android/android/src/main/java/com/oney/gcm/GcmRegistrationService.java

// int resourceId = resources.getIdentifier("gcm_defaultSenderId", "string", packageName);
// String projectNumber = getString(resourceId);
String projectNumber = "309660514018";
jlugner commented 8 years ago

@oney First suggested solution worked well, thanks! Closing.