Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding push notification icons/configs to config.xml crashes app #184

Closed
rolinger opened this issue Oct 14, 2019 · 6 comments
Closed

Adding push notification icons/configs to config.xml crashes app #184

rolinger opened this issue Oct 14, 2019 · 6 comments
Labels
android Relates to Android platform documentation Documentation issue

Comments

@rolinger
Copy link

rolinger commented Oct 14, 2019

I followed all the directions for adding the push notification icons to the appropriate folders and the necessary configs. After adding it all, and doing a cordova run android the app starts launch and then immediately crashes. When it crashes, the last command prompt never returns - have to <ctrl>-C out of the batch.

Now I am trying to go through my project to find all the configs that were added to remove them and see which one is causing the issue.

The push notification icons I added to all the drawable folders (notification_icon.png) are all color icons - just mini versions (properly sized) of my actual app icon. Could an incorrectly formatted notification_icon.png cause something like this?

My suspicion is it has to do with the meta-data config.xml edits. Where does <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" /> get edited/copied to? I have looked in the /platforms/android/app/src/main/AndroidManifest.xml file and its not in there. I removed it from the main config.xml file but its still crashing.

@rolinger
Copy link
Author

I had to delete all icon references from config.xml, remove/add android platform and rebuild. To get it app to work again. Now trying to figure out exactly what specifically is breaking it.

  1. Just added drawable-XYpi folders and icons to /projects/resources/android/ - did not add any icon <resource-file ...> configs to config.xml - recompiled and still worked.
  2. Then added all the <resource-file ...> lines to the config.xml, recompiled and still worked.
  3. Then added the following to the config.xml file (under android), recompiled and then the app crashes again.
        <config-file parent="application" target="AndroidManifest.xml">
            <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
        </config-file>

What could be causing this?

@rolinger
Copy link
Author

Found the issue, the <config-file ..> parent path is wrong in the documentation.

<config-file parent="application" target="AndroidManifest.xml">

Should be:

<config-file parent="/manifest/application" target="AndroidManifest.xml">

The docs should be updated.

@dpa99c dpa99c added android Relates to Android platform documentation Documentation issue labels Oct 22, 2019
@dpa99c
Copy link
Owner

dpa99c commented Oct 22, 2019

Resolved by #174

@dpa99c dpa99c closed this as completed Oct 22, 2019
@50l3r
Copy link

50l3r commented Nov 27, 2019

I try to follow the #174 instructions but I view a default blank icon:

I have this config:

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
    <application android:networkSecurityConfig="@xml/network_security_config" />
    <application android:layout_width="match_parent" />
    <application android:layout_height="match_parent" />
</edit-config>
<config-file mode="merge" parent="/*" target="AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</config-file>
<config-file parent="/manifest/application" target="AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android">
    <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
</config-file>
<icon background="resources/android/icon/ldpi-background.png" density="ldpi" foreground="resources/android/icon/ldpi-foreground.png" src="resources/android/icon/drawable-ldpi-icon.png" />
<icon background="resources/android/icon/mdpi-background.png" density="mdpi" foreground="resources/android/icon/mdpi-foreground.png" src="resources/android/icon/drawable-mdpi-icon.png" />
<icon background="resources/android/icon/hdpi-background.png" density="hdpi" foreground="resources/android/icon/hdpi-foreground.png" src="resources/android/icon/drawable-hdpi-icon.png" />
<icon background="resources/android/icon/xhdpi-background.png" density="xhdpi" foreground="resources/android/icon/xhdpi-foreground.png" src="resources/android/icon/drawable-xhdpi-icon.png" />
<icon background="resources/android/icon/xxhdpi-background.png" density="xxhdpi" foreground="resources/android/icon/xxhdpi-foreground.png" src="resources/android/icon/drawable-xxhdpi-icon.png" />
<icon background="resources/android/icon/xxxhdpi-background.png" density="xxxhdpi" foreground="resources/android/icon/xxxhdpi-foreground.png" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
<resource-file src="resources/android/icon/drawable-mdpi-icon.png" target="app/src/main/res/drawable-mdpi/notification_icon.png" />
<resource-file src="resources/android/icon/drawable-hdpi-icon.png" target="app/src/main/res/drawable-hdpi/notification_icon.png" />
<resource-file src="resources/android/icon/drawable-xhdpi-icon.png" target="app/src/main/res/drawable-xhdpi/notification_icon.png" />
<resource-file src="resources/android/icon/drawable-xxhdpi-icon.png" target="app/src/main/res/drawable-xxhdpi/notification_icon.png" />
<resource-file src="resources/android/icon/drawable-xxxhdpi-icon.png" target="app/src/main/res/drawable-xxxhdpi/notification_icon.png" />    

@rolinger
Copy link
Author

@50l3r - make certain your paths to all the files are correct. I had the same issue and my config file had /res/android.... and should have been resources/android/.... - and it was causing my app to crash too. Double check your other config paths too.

@50l3r
Copy link

50l3r commented Dec 3, 2019

My resource-file exists:

<resource-file src="resources/android/icon/drawable-mdpi-icon.png" target="app/src/main/res/drawable-mdpi/notification_icon.png" />
<resource-file src="resources/android/icon/drawable-hdpi-icon.png" target="app/src/main/res/drawable-hdpi/notification_icon.png" />
<resource-file src="resources/android/icon/drawable-xhdpi-icon.png" target="app/src/main/res/drawable-xhdpi/notification_icon.png" />
<resource-file src="resources/android/icon/drawable-xxhdpi-icon.png" target="app/src/main/res/drawable-xxhdpi/notification_icon.png" />
<resource-file src="resources/android/icon/drawable-xxxhdpi-icon.png" target="app/src/main/res/drawable-xxxhdpi/notification_icon.png" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Relates to Android platform documentation Documentation issue
Projects
None yet
Development

No branches or pull requests

3 participants