Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Android™ Runtime Development

Reply
Contributor
simpsoff
Posts: 12
Registered: ‎01-22-2013
My Device: DevAlpha
My Carrier: Koodo
Accepted Solution

BlackBerry 10 Android Runtime PUSH Problem

[ Edited ]

I am having a problem with my BB10 Android runtime, it fails when attempting to contact GCM, and therefore does not send in a valid push token to our server.

 

I have followed the instructions here to the letter: http://developer.blackberry.com/android/apisupport/creating_push-enabled_android_apps.html

 

My BAR file has /android/android.cfg which looks like:

<?xml version="1.0" encoding="utf-8"?> 
<android> 
   <push>
      <appid>215-513Bxxxxxxxxxxxxxxxxxxxxxxxxxxxx</appid> 
      <ppgurl>http://cp215.pushapi.na.blackberry.com</ppgurl> 
      <tokenprefix>bb-</tokenprefix>
   </push>
</android>

The credentials are production and have been working when we tested them.

 

/META-INF/MANIFEST.MF has the following line automatically added to it through the Blackberry Nature plugin:

Entry-Point-User-Actions: access_internet,read_geolocation,access_shared,play_audio,post_notification
Entry-Point-System-Actions: _sys_use_consumer_push

Archive-Asset-Name: android/android.cfg
Archive-Asset-SHA-512-Digest: 0iYhu0YnKDy8vnMxTElTXSD-oEXw8vvVBSBxDI_LxcR_B4w53SoXBW7NbRMAD-ZYmQDnMs_aUQrQaNEssmp36Q

 The application works fine with android pushes, but it does not work with my BlackBerry 10 Dev Alpha, and we also tried with a Z10. The DEV Alpha us running OS 10.2.0.341.

 

There were a couple BlackBerry Verification Problems that I'm not sure if they are of any relevance or not:

 

targetSdkVersion: 17 is higher than 10:required minimal OS version=10.2
uses-permission: com.google.android.c2dm.permission.RECEIVE:required minimal OS version=10.0.9

 the OS is running version 10.2.0.341 on the DevAlpha though.

 

Edit: added trouble spot:

 

When debugging the application on the devalpha, using the standard GoogleCloudMessage tools, the call

 

int googlePlayCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
		Log.i("GooglePlayCode", "Code:" + googlePlayCode);
		if (googlePlayCode == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED
				|| googlePlayCode == ConnectionResult.SERVICE_MISSING
				|| googlePlayCode == ConnectionResult.SERVICE_DISABLED) {
			GooglePlayServicesUtil.getErrorDialog(googlePlayCode, this, 1).show();
		}
		else if (googlePlayCode == ConnectionResult.SUCCESS) {
			regid = getRegistrationId();
			Log.i("RegistrationId", "regid:" + regid);
	        if (regid.length() == 0) {
	        	getSenderIdThenRegisterBackground();
	        }
	        gcm = GoogleCloudMessaging.getInstance(this);
		}

 this part:

int googlePlayCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

 returns 9, which from here: http://developer.android.com/reference/com/google/android/gms/common/ConnectionResult.html#SERVICE_I...

 

is SERVICE_INVALID.

 

EDIT:

I tested gcm by skipping the check for GCM avaliability, and my code attempts to register with GCM VIA:

String msg = "";
	            try {
	                if (gcm == null) {
	                    gcm = GoogleCloudMessaging.getInstance(context);
	                }
	                regid = gcm.register(senderId);
	                msg = "Device registered, registration id=" + regid;

	                // Save the regid - no need to register again.
	                setRegistrationId(regid);
	                
	                // Send the registration ID to our server over HTTP,
	                // so it can use GCM/HTTP or CCS to send messages to our app.
	                sendRegistrationInfo(context, regid);
	            } catch (Exception ex) {
	                StringWriter sw = new StringWriter();
	                ex.printStackTrace(new PrintWriter(sw));
	                String exceptionAsString = sw.toString();
	                msg = "Register Error :" + exceptionAsString;
	                //msg = "Register Error :" + ex.toString();
	            }

 which throws an exception, with the stack trace:

java.io.IOException: SERVICE_NOT_AVAILABLE
	at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source)
	at com.joemobi.APP_ID.JoeMobiActivity$9.doInBackground(JoeMobiActivity.java:887)
	at com.joemobi.APP_ID.JoeMobiActivity$9.doInBackground(JoeMobiActivity.java:1)
	at android.os.AsyncTask$2.call(AsyncTask.java:287)
	at java.util.concurrent.FutureTask.run(FutureTask.java:234)
	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
	at java.lang.Thread.run(Thread.java:856)

 

Please help!!!!!!!!!!!!!!!!!!!!!!!!!!!

 

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: BlackBerry 10 Android Runtime PUSH Problem (GooglePlayServicesUtil.isGooglePlayServicesAvailable() returns SERVICE_INVALID)

I'm going to guess you probably want to ask this in http://supportforums.blackberry.com/t5/Android-Runtime-Development/bd-p/adt instead of here, because this forum (judging by its description) is specifically for "Discussion topics regarding the development of server side applications that use BlackBerry Push technology. "

If I'm right, you could click "Report inappropriate content" next to your post and ask a moderator to move the thread there.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Contributor
simpsoff
Posts: 12
Registered: ‎01-22-2013
My Device: DevAlpha
My Carrier: Koodo

Re: BlackBerry 10 Android Runtime PUSH Problem (GooglePlayServicesUtil.isGooglePlayServicesAvailable() returns SERVICE_INVALID)

[ Edited ]

Thanks, thread is now in the proper location.

Please use plain text.
Contributor
simpsoff
Posts: 12
Registered: ‎01-22-2013
My Device: DevAlpha
My Carrier: Koodo

Re: BlackBerry 10 Android Runtime PUSH Problem (GooglePlayServicesUtil.isGooglePlayServicesAvailable() returns SERVICE_INVALID)

Added more detail, and a stack track of what happens when trying to register.

 

This seems very similar to http://supportforums.blackberry.com/t5/BlackBerry-Push-Development/Blackberry-Push-SERVICE-NOT-AVAIL... but i don't see a solution posted.

 

I've checked my device debug token, it has the Debug-Token-System-Actions: _sys_use_consumer_push, and the BAR manifest has the Entry-Point-System-Actions: _sys_use_consumer_push

 

My device also has the blackberry symbol beside the wifi.

Please use plain text.
BlackBerry Development Advisor (Retired)
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: BlackBerry 10 Android Runtime PUSH Problem (GooglePlayServicesUtil.isGooglePlayServicesAvailable() returns SERVICE_INVALID)

A possible cause to this issue is using the Google Play Service SDK to enable GDM. The Google Play Service is not supported on BlackBerry 10 which is why any reference to GCM APIs would fail.

 

Using the stand-alone GCM library should still work on BlackBerry 10 and is still stated to be supported by Google:

"The client helper library that was offered in previous versions of GCM still works..."

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.
Contributor
simpsoff
Posts: 12
Registered: ‎01-22-2013
My Device: DevAlpha
My Carrier: Koodo

Re: BlackBerry 10 Android Runtime PUSH Problem (GooglePlayServicesUtil.isGooglePlayServicesAvailable() returns SERVICE_INVALID)

[ Edited ]

Thanks for the info Garett, I'll try using that instead.

 

Since the Google Play Service SDK is the officially recomended way of supporting GCM on android right now, I would recommend adding that info to this document: http://developer.blackberry.com/android/apisupport/creating_push-enabled_android_apps.html

 

I will let you know after I try the standalone GCM Helper Lib. Thanks!

Please use plain text.
BlackBerry Development Advisor (Retired)
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: BlackBerry 10 Android Runtime PUSH Problem (GooglePlayServicesUtil.isGooglePlayServicesAvailable() returns SERVICE_INVALID)

I agree and am working with the appropriate teams to make this change.

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.
Contributor
simpsoff
Posts: 12
Registered: ‎01-22-2013
My Device: DevAlpha
My Carrier: Koodo

Re: BlackBerry 10 Android Runtime PUSH Problem (GooglePlayServicesUtil.isGooglePlayServicesAvailable() returns SERVICE_INVALID)

Reworking the code to use the older GCM Lib worked! Thanks!

Please use plain text.