Android GCM Registration is failing - java

I am working on Google cloud messaging service in my android app. For this I need to register my android app to GCM server.
The gcm registration is failing.
I have checked:
The gcm register code is Async call.
The sender id (project id) is correct.
The manifest file is as per the google doc. http://developer.android.com/google/gcm/client.html
My device has google account set up.
I have tried both the cases - add google-play-services jar and import it as project.
I even went on to specify the version number (com.google.android.gms.version) in manifest as per this http://developer.android.com/google/play-services/setup.html#Setup
Where and why would this be failing?
When I catch the exception, exception cause is NULL.
I had done a demo app for this GCM part and it was working fine. I had used Eclipse with JellyBean SDK.
I extended this project to make the current app - package stucture remains same. But now am on Kitkat SDK.
I used the same Sender Id as before to register with GCM. It failed giving null id. I created new project at cloud console and used its project number as sender id. Still same error. Registration Id is null. I don't think Sender Id should be any issue.
Any help would be appreciated.

So is GCMRegistrar Class giving out, that it failed to register?
i think it could be your Manifest file - check everything correctly until you are really sure you did everything right.
I had an other problem when i implemented GCM into my Project. It was giving out "Regestration OKay" but the REG_ID from GCM Server that i needed to read out, was giving me an Empty (not NULL) it was empty LOL.
I moved my MainActivity (where the regestration happens) in the "original" package of my project and it worked.

please follow Push Notification via GCM
if key for browser apps doesn't work, then create key with ip locking and replace it into your config.php file, it will sure work.
please also check whether your client side code works properly or not on this site

I am getting the GCM Registration Id now. I made two changes.
Removed debuggable=false from Manifest file. Wrote a code in the activity to check for version of Play Store.
So conclusion, it was the issue with play store version may be.

Related

Firebase UI authentication with google fails with message (code:10 message:10)

I've made a chat app that uses Firebase's feature Real-time database.
I face a problem with google authentication. The problem started when I downloaded the app from the Play Store, the authentication was working perfectly when I was running the app in debug mode. When users try to sign in they get a toast message code:10 message:10.
I would like to note here that: I've added the SHA1 fingerprint. How can I solve this?
*Not sure if this is helpful but I've followed step by step this tutorial
You need three keys in order to make it work:
The debug key. Informations here.
The release key. Informations here.
Google Play App signing key. Informations here.
All these keys are needed in order to make the sign-in process work.
Other informations here.
After generating SHA1 for release key, I forgot downloading the new google-service.json file that caused the same error.
Make sure you follow the instruction https://developers.google.com/android/guides/client-auth to generate and add debug/release SHA1 to firebase console and download google-service.json after updated.
If you use Use app signing by Google Play option, you need an additional step:
After uploading app into google play console, go to Release management > App signing, copy SHA1 and paste to firebase console
Update
In the new google play console, the App signing key can be found as following:
Setup > App signing
Make sure you have added signed SHA1. If you are using debug one then it will not gonna work for live apk.
You need to put "debug.keystore" in this path C:\Users\USER_FOLDER_NAME.android
then in Android studio follow the below steps
1. Run your project
2. Click on Gradle menu
3. Expand Gradle Tasks tree
4. Double click on android -> signingReport
You can see SHA in Run Tab
for more information see link
For me the problem was that i registered app and enabled google signin on Firebase console but I was testing with the debug version of app which has slightly different package name (same name but ended with .debug) so it was not working because the debug app is not yet registered. so additionally to my release app i also added the debug app to the firebase project for the app and it generated it's own google-services.json which i download and set to src/debug/google-services.json.
I believe this might be useful to some one else.

Firebase Cloud Messaging not working on some devices

I have a problem with sending push notifications from server via FCM.
So at first everything was working fine after adding push notifications.
I had to change the package name of an android app so I added new app on Firebase with new package name and I have downloaded new json file, and changed the name in manifest file and gradle.
After doing it, I noticed that on some smartphones these notifications aren't working and on others they work :/
When I'm using only Firebase to send push notification (the firebase console) - it works. But when I receive the push notification from server on one phone, on another I don't.. I am updating the regId in my database and all notifications on my phone are turned ON. I thought that maybe the problem is that I have 2 apps in one project in firebase, so I made new project and again downloaded json file but it is the same as earlier.
Have anyone had this kind of problem or anyone knows what could solve it and make it work again? :/
Really depends on device you were trying it on.
if the google play services is out of date you could try updating it from playstore.see if that fixes the problem.
if it has no google api/Playstore (so no amazon products and some none market devices)
push messaging does not work along with authentication. The realtime Data base still works but fires off an error in logcat.
ive been pulling my hair out for weeks trying to figure it out.. thought it was my code.. so i sent the firebase team a email to ask. They confirmed that there was no fix for this at the present time.. hope this helps

Android AWS Cognito: unable to resolve host

I am having difficulty getting Cognito registration and login to work for my app in Android Studio using this sample. When I attempt to log in via the simulator, the app works for a few seconds, then displays an error message: "Unable to execute HTTP request: Unable to resolve host 'cognito-idp.us-east-1.amazonaws.com': No address associated with hostname". This same error is the only error that appears in the console. I have seen similar questions and tried solutions such as checking to ensure my app has the permissions android.permission.INTERNET and android.permission.ACCESS_NETWORK_STATE, but the error persists. It also doesn't seem to be a network issue. I have updated to the latest version of the Android SDK as well as the AWS SDK, and the problem persists.
I currently I have a Cognito user pool set up which works properly for login on the iOS version of my app. Following the instructions in the readme for the sample code, I added an app to my existing user pool, and then copied and pasted the newly generated app client ID and app client secret into AppHelper.java for clientId and clientSecret respectively. I also set userPoolId to the ID listed for my user pool under "pool details" in the Cognito conosle, and cognitoRegion to US East, since this is the region of my user pool. I noticed that there was no need for me to set the pool name, as there was in the iOS version, so I'm wondering if that's something I need to do.
Sorry if this counts as a duplicate, but I wanted to post a question with the exact error message I encountered and the steps I took, and I'm wondering if someone has managed to get this specific sample working and what I should do.
The problem has been resolved, but unfortunately I'm not quite sure what fixed it since I didn't change anything in the code. All I did was install an update, so anyone with a similar problem should probably ensure that all SDKs used in the sample are properly updated, along with the simulator. It's also worth noting that I was using a different network than in my previous tests, so it's possible that it was a network issue after all.
I had the same issue.
The issue occurred when I used a VPN with emulator to test my program. The reason was that the internet connection in the emulator was too slow when connecting through a VPN.
This could also happen if your internet connection is not strong enough.
The solution is, use a real android device to test your code, if your internet connection is not good enough.
More info: https://github.com/aws-amplify/aws-sdk-android/issues/567

Android License Test Response always response an ERROR_NOT_MARKET_MANAGED

I create my app header on Google Play.
I create an application with google's LVL library.
I sign into an Android device with the same account that I use to sign into my Google Play Developer Console.
The LicenseChecker was using the correct public key (from Google Play app license key).
Clearing my Google Play cache and not having uploaded the application, but the license server needs a response set on the license test setting page, no?
when I'm running the app, the license server always responds: 3 (ERROR_NOT_MARKET_MANAGED).
I wait 24 hours, but nothing happens. The response is 3.
I upload the app (same version code) to the google play, but not published.
I wait 24 hours again, but nothing happens. The response is 3.
WTF :)
Okay, just back to the beginning step by step:
I create an app from the Android SDK's licensing sample.
The LVL version is 2.
I make a header on google play.
A BASE64_PUBLIC_KEY rewrite in the sample from a google play app license.
I sign in an android device with my publisher's account (after factory reset)
This sample is returned 3!
What's wrong with me????
I hope I can answer this question and I am able to help You, but if this answer does not help You, please show some code maybe it´s a simple coding Problem.
I had the similar problem for long Time, all my licensed apps had not worked (for me, but never get a negative response from users). I discovered two things: first, eclipse allways shows an error on my library project. This caused the warning on my licensed apks, that the reference to this library is not valid. In the past, I just cleared the "Problems" history and than it worked. What I have seen is, at the library manifest there was the targetSdk included:
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="17"/>
But the library project does not support the tag targetSdkVersion, so I deletet it:
<uses-sdk android:minSdkVersion="3" />
After this, the error is gone and all licensed projects seems to be good. The seond problem is, since some time, saving apps as drafts is no longer supported like described here:
http://developer.android.com/google/play/billing/billing_testing.html#draft_apps
So, what You have to do is, upload Your apk to the alpha or beta test inside the console and publish it. This app could not be seen from other poeple, as long as You give the rights to some google groups for testing it. I set my response inside the console again to LICENSED and saved it. After waiting some time (up to 24 hours) until google play has noticed the changes, it worked.
I too have often got ERROR_NOT_MARKET_MANAGED unexpectedly.
My problem was that I was using my main developer Gmail address as my testing account and my app was a paid app.
To fix my problem:
- I had to create a 2nd Gmail account,
- add it to my list of testers (click Settings on your Google Play Developer account to get the right screen),
- add that new Gmail account to the list of accounts on the mobile device you want to test on,
- then delete whatever version of your app you do have on your device,
- then load it using download through Google Play.
When you tap Google Play to start it (touch "play games") you'll see what Gmail account you are inside Google Play in the upper left of the screen. Change that to be your new testing account.
NOW you can download your paid app (it never would let you before you did all this) and (hopefully) you will no longer get ERROR_MARKET_MANAGED.
How are you likely to encounter this error? In roughly, 3 ways.
Let's assume that in LicenseChecker in method checkAccess that after the line:
if (bindResult) {
that you have put the line:
System.println("good bind");
and that in LicenseValidator in method verify you have placed:
System.out.println("signature verified");
in the line Before the line:
} catch (NoSuchAlgorithException e) {
Make sure you've gone to a new version number, upload to alpha, wait a while, then run. If you see:
good bind
signature verified
in the trace output and the error you get is ERROR_NOT_MARKET_MANAGED then I would say you've triggered this particular problem.
If in method verify in LicenseValidator you put:
System.out.println("begin verify call:" + responseCode);
after ResponseData data = null;
and prep-then-run then you see:
begin verify call:561
then you might be having this problem.
If you set DEBUG_LICENSE_ERROR to true in LicenseChecker and in wherever it is that you have put applicationError in your LVL initiation code you put:
String result = String.format("Application error: %1$s", errorCode);
System.out.println("result:" + result); //or display it on screen using a Toast
and prep-then-run and see
result: Application error:3
then you might be having this problem.
What makes this a particularly nasty thing to encounter is that when you set the testing response for this app to anything other than "respond normally" then your app behaves like it is responding perfectly to match to presently set license response.
However..when you set the test response to "respond normally" then you're going to always get ERROR_NOT_MARKET_MANAGED (if the app is paid and you're trying to use your primary Gmail account on your test device).

Android c2dm push notifications after app reinstall

I have the following question:
I've successfully implemented C2DM in my application. I'm registering to both google c2dm cloud and a custom server that "creates" notification contents. Everything is working fine.
My question is : what happens when i uninstall my app and then reinstall it on the same device? I've noticed that C2DM is sending me back the same app_key, so apparently there's no way to determine my app installation status change. And i keep on receiving old push notification (they're customized by user preferences in the app).
I won't be able to test with a google play published app until final release, so i would like to know if there's a chance that google itself could notify c2dm that the app was uninstalled on my device and force it to change my app_id at next restart.
Thanks in advance
Stefano
From what I understand in C2DM, you shouldn't depend on Google's registration ID by itself. They "promise" nothing - you might even get a new registration ID without a clear reason (might be their own vrsion upgrades, etc.).
If you want to follow installation - you should do it with your own server - create a unique identifier whenever the app asks for registration, and use it and not the Google's registration ID.
Regarding to Google Play - couldn't find a difference between published app and unpublished one - the behavior seems to be the same.
Hope this helps somehow.
Shushu

Categories