Android Question FirebaseNotifications & manifest error

Yayou49

Active Member
Licensed User
Hi,

I did implement the firebase notification in my project, as describe in thread https://www.b4x.com/android/forum/t...-messages-firebase-cloud-messaging-fcm.67716/.
As requested, I've added 3 new lines in my manifest:

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

While compiling, at the end, I'm facing an 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]

If I check in manifest.xml line 14, I've got:
<permission android:name="xxxx.V1.permission.C2D_MESSAGE"
android:protectionLevel="signature" />

Does someone know what about this error ?
 

DonManfred

Expert
Licensed User
Longtime User
What is the complete manifest-editor code?
 
Upvote 0

Yayou49

Active Member
Licensed User
What is the complete manifest-editor code?

Manifest in B4A:
B4X:
'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.Firebase)
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)

AddManifestText(<permission
  android:name=".$PACKAGE$.permission.MAPS_RECEIVE"
  android:protectionLevel="signature"/>
  <uses-feature android:glEsVersion="0x00020000" android:required="true"/>)
AddApplicationText(
<meta-data
  android:name="com.google.android.geo.API_KEY"
  android:value="AIzxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"/>
  <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")

AddManifestText(<uses-feature android:name="android.hardware.telephony" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.camera" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.camera.flash" android:required="false" />)
AddManifestText(<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />)

AddPermission("android.permission.INTERNET")
AddPermission("android.permission.READ_PHONE_STATE")
AddPermission("android.permission.CAMERA")
AddPermission("android.permission.FLASHLIGHT")
AddPermission("android.hardware.camera")

SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetActivityAttribute(Photo, android:screenOrientation, "portrait")

AddManifestText(<uses-permission
    android:name="android.permission.WRITE_EXTERNAL_STORAGE"
    android:maxSdkVersion="18" />)

AddApplicationText(<provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
  )
CreateResource(xml, provider_paths,
   <external-files-path name="name" path="" />)
 
AddPermission(android.permission.REQUEST_INSTALL_PACKAGES)
 
Last edited:
Upvote 0

Yayou49

Active Member
Licensed User
Start with a new Manifest.

Even if I clean my manifest like this:

B4X:
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.Firebase)
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)

Result is the same ....
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
and the json from firebase in your projectdir is matching the packagename of your app?
And you are using B4A SDK MAnager?
And you are have configured the right SDK in Tools-Configure paths?

I just created a new project, downloaded the json for the project from firebaseconsole

My Manifest

B4X:
'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="16" 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$")
'End of default text.
CreateResourceFromFile(Macro, Themes.DarkTheme)
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)

and the Usually FirebaseMessaging Service Module.
B4A Version: 8.30 BETA #1
Parse den Code. (0.00s)
Kompiliere den Code. (0.06s)
Kompiliere Layoutcode. (0.00s)
Organisiere Libraries. (0.00s)
Generiere R Datei. (0.24s)
Kompiliere generierten Java Code. (1.03s)
Byte-Code konvertieren - optimiert dex. (6.56s)
Packe Dateien. (0.74s)
Kopieren von Bibliothek Ressourcen (0.04s)
Found 15 resource files.
Signiere Paketdatei (privater Key). (0.76s)
ZipAlign file. (0.05s)
Installiere Datei auf Gerät. (8.60s)
Device serial: 988ad036525346515630
Erfolgreich abgeschlossen.
It compiles successflly without malformed Manifest
 
Upvote 0

Yayou49

Active Member
Licensed User
- yes my json seems to be clear:
B4X:
 "client": [
    {
      "client_info": {
        "mobilesdk_app_id": "1:xxxxxxxx347:android:xxxxxxx2da89996",
        "android_client_info": {
          "package_name": "xxxx.V1"
        }
      },

- yes I'm using B4A SDK manager and all needed updates are done.
- SDK is set to sdk 26

I have created a new small project to see if it works.
On this small project, I have a new error.
Don't know if it can be linked with the previous one:
*** Service (firebasemessaging) Create ***
firebasemessaging_service_create (java line: 201)
java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process xxxx.V1. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(SourceFile:218)
at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
at com.google.firebase.messaging.FirebaseMessaging.getInstance(Unknown Source)
at anywheresoftware.b4a.objects.FirebaseNotificationsService$FirebaseMessageWrapper.Initialize(FirebaseNotificationsService.java:97)
at xxxx.V1.firebasemessaging._service_create(firebasemessaging.java:201)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at xxxx.V1.firebasemessaging.onCreate(firebasemessaging.java:56)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3162)
at android.app.ActivityThread.-wrap5(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1550)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
 
Upvote 0

Yayou49

Active Member
Licensed User
I've set path to platforms/android-27/android.jar as you said.
Package name is fully the same in json and in package/configuration

I'm not able to upload the file in the forum (too large) ....
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I'm not able to upload the file in the forum (too large) ....
do not zip the file manually. Use File-Export as ZIP
What does the zip grow? Do you have a lot of files in the assets?

Otherwise you need to upload it on GoogleDrive or Dropbox and post a link
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
the json file is mission. i can not test it without. If you defined a SHA Signature then i can not test it at all as my signature is another one.

"Default FirebaseApp is not initialized"

This sounds like the newly created app/project is not known at firebase widely.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Here is the json
B4A Version: 8.30 BETA #1
Parse den Code. (0.00s)
Kompiliere den Code. (0.08s)
Kompiliere Layoutcode. (0.00s)
Organisiere Libraries. (1.03s)
Generiere R Datei. (1.29s)
Kompiliere generierten Java Code. (0.91s)
Byte-Code konvertieren - optimiert dex. (5.38s)
Packe Dateien. (0.68s)
Kopieren von Bibliothek Ressourcen (0.03s)
Found 15 resource files.
Signiere Paketdatei (privater Key). (0.76s)
ZipAlign file. (0.05s)
Installiere Datei auf Gerät. (10.04s)
Device serial: 988ad036525346515630
Erfolgreich abgeschlossen.

Your project compiles fine and is running on my device.
 
Upvote 0

Yayou49

Active Member
Licensed User
Sorry to bother you, but I really need to understand what going on with this project ...
 

Attachments

  • FireBase.jpg
    FireBase.jpg
    122.9 KB · Views: 312
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I only can answer regarding the testproject you just created
Token: dPC32eQvnZU:APA91bEOh-7_KSo6E1bHvBDtcE9u_vTPnnva_LjTFm1fgGWvMxHbiMRmKQYuBtFiGD3O_jm0fZKwxcDvAv3VmLRczR4x7N22A7_drAWUTtWTtFp7g7XFPUUD9sguznlG4LgmhmBqB8Jz
This is the token i got...

I expect the project running on your machine too now. Maybe it just took some time till your project is known
 
Upvote 0

Yayou49

Active Member
Licensed User
.... sorry but where can I check this token on my side ???? (really not confident with this part)
 
Upvote 0
Top