Android Question Malformed Manifest in uppercase characters in package name and Firebase services

Hadi57

Member
Hi everybody

I used uppercase character in one of my published games, therefore I can’t use Firebase services (cloud messaging), I get INSTALL_PARSE_FAILED_MANIFEST_MALFORMED error message while compiling.
As I have more than +5M installs in Google play I can’t change package name and release new app.
is there any way to give [Packagemame].C2D_MESSAGE permission to app??, I found this page (https://developercommunity.visualst...anifest-when-having-uppercase-characters.html) that seems there is a way in Xamarin, is there any equivalent way in B4A to solve this problem?
I will be appreciated if anyone could help me.
 

Erel

Administrator
Staff member
Licensed User
You can of course change the manifest file in any way you like.

When you add this line to the manifest editor:
B4X:
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)

The following code is added:
B4X:
CreateResourceFromFile("google-services", "google-services.json")
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.WAKE_LOCK)
AddPermission(com.google.android.c2dm.permission.RECEIVE)
AddPermission(${applicationId}.permission.C2D_MESSAGE)
AddPermission(com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE)
AddManifestText( <permission android:name="${applicationId}.permission.C2D_MESSAGE"
  android:protectionLevel="signature" />)
AddApplicationText(
 <receiver
            android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
            android:enabled="true"
            android:exported="false" >
        </receiver>

  <service
            android:name="com.google.android.gms.measurement.AppMeasurementService"
            android:enabled="true"
            android:exported="false" />
            
 <receiver
            android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
            android:enabled="true"
            android:exported="true"
            android:permission="android.permission.INSTALL_PACKAGES" >
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
</receiver>
<service
            android:name="com.google.android.gms.measurement.AppMeasurementJobService"
            android:enabled="true"
            android:exported="false"
            android:permission="android.permission.BIND_JOB_SERVICE" />

 <service android:name="com.google.firebase.components.ComponentDiscoveryService"  android:directBootAware="true" >
            <meta-data
                android:name="com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
             <meta-data
                android:name="com.google.firebase.components:com.google.firebase.iid.Registrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
             <meta-data
                android:name="com.google.firebase.components:com.google.firebase.auth.FirebaseAuthRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
             <meta-data
                android:name="com.google.firebase.components:com.google.firebase.storage.StorageRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
            <meta-data 
                android:name="com.google.firebase.components:com.google.firebase.firestore.FirestoreRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar"/>

            <meta-data
                    android:name="com.google.firebase.components:com.google.firebase.database.DatabaseRegistrar"
                    android:value="com.google.firebase.components.ComponentRegistrar"/>
                <meta-data
                android:name="com.google.firebase.components:com.google.firebase.messaging.FirebaseMessagingRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
             <meta-data
                android:name="com.google.firebase.components:com.google.firebase.installations.FirebaseInstallationsRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
              <meta-data
                android:name="com.google.firebase.components:com.google.firebase.crashlytics.CrashlyticsRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
               
</service>
   <provider
  android:authorities="${applicationId}.firebaseinitprovider"
  android:name="com.google.firebase.provider.FirebaseInitProvider"
  android:exported="false"
   android:directBootAware="true"
  android:initOrder="100" />
  
   <receiver
  android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
  android:exported="true"
  android:permission="com.google.android.c2dm.permission.SEND" >
  <intent-filter>
  <action android:name="com.google.android.c2dm.intent.RECEIVE" />
  <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
  <category android:name="${applicationId}" />
  </intent-filter>
  </receiver>
    <receiver
  android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
  android:exported="false" />


  <service
  android:name="com.google.firebase.iid.FirebaseInstanceIdService"
  android:exported="true">
  <intent-filter android:priority="-500">
  <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
  </intent-filter>
  </service>
)

Directly add the code and replace ${applicationId} with whatever you like.
 
Upvote 0

Hadi57

Member
You can of course change the manifest file in any way you like.

When you add this line to the manifest editor:
B4X:
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)

The following code is added:
B4X:
CreateResourceFromFile("google-services", "google-services.json")
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.WAKE_LOCK)
AddPermission(com.google.android.c2dm.permission.RECEIVE)
AddPermission(${applicationId}.permission.C2D_MESSAGE)
AddPermission(com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE)
AddManifestText( <permission android:name="${applicationId}.permission.C2D_MESSAGE"
  android:protectionLevel="signature" />)
AddApplicationText(
<receiver
            android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
            android:enabled="true"
            android:exported="false" >
        </receiver>

  <service
            android:name="com.google.android.gms.measurement.AppMeasurementService"
            android:enabled="true"
            android:exported="false" />
          
<receiver
            android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
            android:enabled="true"
            android:exported="true"
            android:permission="android.permission.INSTALL_PACKAGES" >
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
</receiver>
<service
            android:name="com.google.android.gms.measurement.AppMeasurementJobService"
            android:enabled="true"
            android:exported="false"
            android:permission="android.permission.BIND_JOB_SERVICE" />

<service android:name="com.google.firebase.components.ComponentDiscoveryService"  android:directBootAware="true" >
            <meta-data
                android:name="com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
             <meta-data
                android:name="com.google.firebase.components:com.google.firebase.iid.Registrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
             <meta-data
                android:name="com.google.firebase.components:com.google.firebase.auth.FirebaseAuthRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
             <meta-data
                android:name="com.google.firebase.components:com.google.firebase.storage.StorageRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
            <meta-data
                android:name="com.google.firebase.components:com.google.firebase.firestore.FirestoreRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar"/>

            <meta-data
                    android:name="com.google.firebase.components:com.google.firebase.database.DatabaseRegistrar"
                    android:value="com.google.firebase.components.ComponentRegistrar"/>
                <meta-data
                android:name="com.google.firebase.components:com.google.firebase.messaging.FirebaseMessagingRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
             <meta-data
                android:name="com.google.firebase.components:com.google.firebase.installations.FirebaseInstallationsRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
              <meta-data
                android:name="com.google.firebase.components:com.google.firebase.crashlytics.CrashlyticsRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
             
</service>
   <provider
  android:authorities="${applicationId}.firebaseinitprovider"
  android:name="com.google.firebase.provider.FirebaseInitProvider"
  android:exported="false"
   android:directBootAware="true"
  android:initOrder="100" />

   <receiver
  android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
  android:exported="true"
  android:permission="com.google.android.c2dm.permission.SEND" >
  <intent-filter>
  <action android:name="com.google.android.c2dm.intent.RECEIVE" />
  <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
  <category android:name="${applicationId}" />
  </intent-filter>
  </receiver>
    <receiver
  android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
  android:exported="false" />


  <service
  android:name="com.google.firebase.iid.FirebaseInstanceIdService"
  android:exported="true">
  <intent-filter android:priority="-500">
  <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
  </intent-filter>
  </service>
)

Directly add the code and replace ${applicationId} with whatever you like.

Hi Erel,
Thank you for your response very much.
I added the code to the manifest, but the "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED" error still exists same as before.
 
Upvote 0

Hadi57

Member
That's expected.

Directly add the code and replace ${applicationId} with whatever you like.

Thank you Erel for your Help.
I put this code and replace ${applicationId} with my package name (Hadiware.Dots_Boxes) at the first time. But the problem still exists.
I minimize my project to illustrate the problem and send in attachment.
I tested that in 4 devices and I got error in device 2, 3, 4. But it runs in device 1 without any problem.
  1. HUAWEI P smart - Android 9
  2. Samsung Galaxy S4 - Android 5
  3. HTC Desire EYE - Android 6
  4. Tablet - Android 4.4.2
I know my package name isn't standard, But i Published that in Google play and now I can’t change package name and release new app.
I will be appreciated if you could help me and save me from this headache.
 

Attachments

  • Compile.jpg
    Compile.jpg
    85.1 KB · Views: 61
  • Dots&Boxes.zip
    143.9 KB · Views: 58
Upvote 0

Erel

Administrator
Staff member
Licensed User
1. You need to remove this line: CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
2. Based on the link you posted in the first post, you need to change the permission to be lower case. The whole idea of the manually adding the code is to let you change it:
Change:
B4X:
AddManifestText( <permission android:name="Hadiware.Dots_Boxes.permission.C2D_MESSAGE"
With:
B4X:
AddManifestText( <permission android:name="hadiware.dots_boxes.permission.C2D_MESSAGE"

3. You can see the generated AndroidManifest.xml file in the Objects folder.
 
Upvote 0

Hadi57

Member
1. You need to remove this line: CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
2. Based on the link you posted in the first post, you need to change the permission to be lower case. The whole idea of the manually adding the code is to let you change it:
Change:
B4X:
AddManifestText( <permission android:name="Hadiware.Dots_Boxes.permission.C2D_MESSAGE"
With:
B4X:
AddManifestText( <permission android:name="hadiware.dots_boxes.permission.C2D_MESSAGE"

3. You can see the generated AndroidManifest.xml file in the Objects folder.


HURRAH, it works like a charm . :) 👍
Thank you dear Erel very very much.
B4A is so great and your support is awesome. I really appreciate for your time, and i hope this thread could help any others that have this problem.
 
Upvote 0
Top