Android Question Problem with Android push notification (GCM)

Yayou49

Active Member
Licensed User
Hi,

Based on Erel's tuto, I'm trying to run the example code (https://www.b4x.com/android/forum/t...otification-gcm-framework-and-tutorial.19226/)

I've registered GCM in google API for my project
I've updated SenderId with mine in B4A code.

With the original code, I get this error:
Service Intent must be explicit: Intent { act=com.google.android.c2dm.intent.REGISTER (has extras) }

I've updated sub "RegisterDevice" with Erel's code proposal:

B4X:
    Dim i As Intent
    If Unregister Then
        i.Initialize("com.google.android.c2dm.intent.UNREGISTER", "")
    Else
        i.Initialize("com.google.android.c2dm.intent.REGISTER", "")
        i.PutExtra("sender", Main.SenderId)
    End If
    Dim jo As JavaObject = i
    jo.RunMethod("setPackage", Array("com.google.android.gms"))
    Dim r As Reflector
    Dim i2 As Intent
    i2 = r.CreateObject("android.content.Intent")
    Dim pi As Object
    pi = r.RunStaticMethod("android.app.PendingIntent", "getBroadcast", _
     Array As Object(r.GetContext, 0, i2, 0), _
     Array As String("android.content.Context", "java.lang.int", "android.content.Intent", "java.lang.int"))
    i.PutExtra("app", pi)
    StartService(i)

and the error became "Not found" on jobdone result.

I ran both code on emulator and real device.

I really don't know what to do ...
Any idea ?
 

BillMeyer

Well-Known Member
Licensed User
Upvote 0

Yayou49

Active Member
Licensed User
Hi BillMeyer,

I did as you said.

While running my app, I get an error about manifest and don't understand why ....
Here is my manifest:

'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.DarkTheme)

CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)

At the end of compilation, I've got this error:

Installation sur le dispositif. Error
adb: failed to install xxxx.apk: Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl1131351572.tmp/base.apk (at Binary XML file line #14): Bad class name xxxx.V1.permission.C2D_MESSAGE in package xxxx.V1]

I've just added the 3 last lines.
 
Last edited:
Upvote 0

Yayou49

Active Member
Licensed User
after some tests, the involved line generated this error is
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)

If I remove this line from the manifest, no error on compilation. Just an error on service start.
 
Upvote 0

Yayou49

Active Member
Licensed User
In fact, it was due to 2 different problems:
- library were not up to date
- effectively, package name was in upper case.
Both corrected and it works.
Thx.
 
Upvote 0
Top