0
votes

I'm developing an Android Module for a Titanium app and I have to generate a Notification. Android SDK forces me to do a setSmallIcon() call to include a png asset as icon for the notification. I've put icon_notification.png asset in /platform/android/res/drawable folder of my module and (tryed to) got it in the code calling

TiRHelper.getResource("drawable.icon_notification")

but when I build module calling ant, the following error is raised:

[javac] Note: [KrollBindingGen] Running Kroll binding generator.
[javac] Note: [KrollBindingGen] No binding data found, creating new data file: org.appcelerator.titanium.bindings/connecthings.json
[javac] Note: [KrollBindingGen] Found binding for proxy Beacon
[javac] Note: [KrollBindingGen] Found binding for module Connect
[javac] Note: [KrollBindingGen] Generating JSON: file:/Users/***/Development/***/modules/android/***/android/build/generated/json/org/appcelerator/titanium/bindings/***.json
[javac] warning: The following options were not recognized by any processor: '[kroll.checkTiContext]'
[javac] /Users/***/Development/***/modules/android/***/android/src/***/***/***/***/ConnectModule.java:76: error: unreported exception ResourceNotFoundException; must be caught or declared to be thrown
[javac]             .setSmallIcon(TiRHelper.getResource("drawable.icon_notification"))
[javac]                                                ^
[javac] Note: /Users/***/Development/***/modules/android/***/android/src/***/***/ti/***/BeaconProxy.java uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 1 error

seems that raising a ResourceNotFoundException exception, builder doesn't find the assset

Have I placed the file in the wrong place?

2
Hi claudio, sdk version? - Jagu
The latest one both for appc CLI and Titanium SDK: 5.2.2, and module is built with android-23 and addon-google_apis-google-23 android SDK and android-ndk-r11b Android NDK - Claudio Bertozzi

2 Answers

0
votes

The platform folder also has to sub-folder of android folder.The full directory is "android/platform/android/res/drawable/". You can also check if the resources are created in the build folder.

Documentation Link

0
votes

Error posted is trowed during build step of the module. In this step I think that resources are not already put in place, so, wrapping the TiRHelper method in a try...catch statement as written in the wiki suggested by @Saeed Sharman resolve the problem.

So, the working version is simply:

try {
  TiRHelper.getResource("drawable.icon_notification");
catch (ResourceNotFoundException e) {
  ...
}