Add resource file to monaca project?



  • so, I would like to add some resource files to support OneSignal notification icons on Android

    https://documentation.onesignal.com/docs/customize-notification-icons#section-3-name-icons-appropriately

    I put the icon files in the tree view under res/android/drawable-<size>/

    I added this to my android platform sections

      <platform name="android">
        <resource-file src="/res/android/drawable-mdpi/ic_stat_onesignal_default.png" target="res/drawable-mdpi/ic_stat_onesignal_default.png" />
    

    I get this error when building

    Build Error: Error: Sandbox Exec Error: [ Error: Source path does not exist: /res/android/drawable-mdpi/ic_stat_onesignal_default.png ]
    

    So, am i doing this completely wrong?

    Thanks


  • Monaca

    @Matt-Nelson In Monaca projects, you can only make changes within www folder. For this reason, you need to use the cordova-plugin-copy-resources plugin to make changes to project files outside of www folder. These changes will be effective after the build. In your case, please do as follows:

    1. Add cordova-plugin-copy-resources plugin into your project.

    2. Within config.xml, change the following line:

      <resource-file src="/res/android/drawable-mdpi/ic_stat_onesignal_default.png" target="res/drawable-mdpi/ic_stat_onesignal_default.png" />
      

      to

      <resource dest="res/drawable-mdpi/" src="www/images/ic_stat_onesignal_default.png" />
      

    Note: You need to put your images source files within www folder such as images folder.

    This should fix your build issue.


Log in to reply