2

I have this on my code:

    Notification notification = new Notification.Builder(Extension.mainContext)
        .setContentTitle(title).setSmallIcon(R.drawable.icon)
        .setContentText(message)
        .setContentIntent(pIntent).build();

When I try to compile it, this happens:

[javac] /.../MainApp.java:42: cannot find symbol
[javac] symbol  : variable icon
[javac] location: class android.R.drawable
[javac]             .setContentTitle(title).setSmallIcon(R.drawable.icon)

Everywhere on Google it says I should put icon.png on res/drawable folder. I'm using Haxe/OpenFl so it generates folders for all resolutions: drawable-hdpi, drawable-ldpi, drawable-mdpi, drawable-xhdpi, and the file is in all of them. Initially I thought it was the lack of an actual "drawable" folder, but I've manually created it and it didn't help.

Does anyone think of anything else that could be impacting this?

Thanks.

ultranol
  • 35
  • 1
  • 6
  • In case anyone else is looking for a fix, just rebuilding the solution fixed the error for me. [source](https://forums.xamarin.com/discussion/7319/release-problem-iv-setimageresource-r-drawable-monoandroidsplash) – user5226582 Sep 19 '17 at 12:20

1 Answers1

6

What does your import statement for R says in this class? It looks like you're importing android.R when you want to import yourpackage.R, or not import any R at all (should also default to your package)

TooManyEduardos
  • 4,206
  • 7
  • 35
  • 66
  • 1
    I had import android.R. Changed it to com.company.package.R and the error is the same. Took it off and it says "package R does not exist". – ultranol Jun 26 '14 at 01:45
  • What IDE are you using? – TooManyEduardos Jun 26 '14 at 01:47
  • Sublime Text 2. It's not an IDE, it's just code. Anyway, I found the issue: this is actually a native extension to my main program which is written in pure Haxe/OpenFl. Turns out it resides in a different package, and the icon is situated on that package. I imported "R" from that package and it worked. Thanks for the insight! – ultranol Jun 26 '14 at 01:50
  • Ohhh. Well I'm glad it helped – TooManyEduardos Jun 26 '14 at 01:51
  • @ultranol I am currently looking for an answer for this question http://stackoverflow.com/questions/25202957/where-to-put-drawable-resources-for-an-openfl-android-extension can you please answer it? also, can you share your code so that I have a very similar situation, thannks – simo Aug 10 '14 at 14:22