Raja0sama / rn-foreground-service

Foreground Service for React Native made with ❤
https://rn-foreground.vercel.app/
148 stars 70 forks source link

error: cannot find symbol #84

Open marcofuentes05 opened 10 months ago

marcofuentes05 commented 10 months ago

Hello,

I have been using this library for the past six months without any major problem. Me and my team love it! However, I just updated my RN to version 0.73.1 (we were using 0.71.3) and now I can't build the app because of a bug in this ligbrary:

node_modules/@supersami/rn-foreground-service/android/src/main/java/com/supersami/foregroundservice/NotificationHelper.java:144: error: cannot find symbol
            notificationBuilder.addAction(R.drawable.redbox_top_border_background, bundle.getString("buttonText", "Button"), pendingBtnIntent);
                                           ^
  symbol:   variable drawable
  location: class R

I don't have a lot of knowledge in android development, but examining the file it seems the error is related to the rendering of buttons in the notification showed when the process is active:

image

Just commenting out lines 144 and 148 makes the error dissappear. I imagine this won't break anything in my app since we don't use buttons in our notifications. But I wonder what caused this issue? And how can I solve it the good way?

fredericosafebox commented 10 months ago

I am facing the same issue.

Raja0sama commented 10 months ago

This clearly means that you are missing this drawable.redbox_top_border_background from the drawables.

On Fri, Jan 19, 2024 at 12:54 AM Frederico Costa @.***> wrote:

I am facing the same issue.

— Reply to this email directly, view it on GitHub https://github.com/Raja0sama/rn-foreground-service/issues/84#issuecomment-1899188643, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHDKCRXFEGC3OIAVRPOHDP3YPGDYHAVCNFSM6AAAAABBOX6ZVOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJZGE4DQNRUGM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Regards, Raja Osama https://rajaosama.me/

fredericosafebox commented 10 months ago

I've never had this file. I've just checked my project's previous version, which was built with RN 0.70.6, and found no drawable.redbox_top_border_background. Lines 144 and 148 that @marcofuentes05 posted were also present by the time, but after I upgraded my RN to 0.73.2 I started having this problem. I wonder what I am trully missing here

This clearly means that you are missing this drawable.redbox_top_border_background from the drawables. On Fri, Jan 19, 2024 at 12:54 AM Frederico Costa @.> wrote: I am facing the same issue. — Reply to this email directly, view it on GitHub <#84 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHDKCRXFEGC3OIAVRPOHDP3YPGDYHAVCNFSM6AAAAABBOX6ZVOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJZGE4DQNRUGM . You are receiving this because you are subscribed to this thread.Message ID: @.> -- Regards, Raja Osama https://rajaosama.me/

GopalVerma1303 commented 10 months ago

I am also facing the same issue. Had anyone solved it? Or would like to suggest any "quick-fix". @marcofuentes05's answer solves the issue but in my case, I have to use buttons too.

Screenshot 2024-01-21 at 2 53 12 PM
fredericosafebox commented 10 months ago

I think that for some reason the class R is not accessible anymore. Maybe related to the RN version (which in my case was upgraded from 0.70.6 to 0.73), because my drawable folder structure remains the same.

fredericosafebox commented 10 months ago

I just checked here: https://developer.android.com/reference/android/R.drawable

R class is still available but it does not have 'redbox_top_border_background' anymore.

Maybe at some point it was removed from android?

If you are trying to access that, I do not think you will succeed anyway,

fredericosafebox commented 10 months ago

Maybe a solution is to use the new Notification.Builder addAction, which was added in API level 20, since it does not require an Icon as parameter. Or pass a valid Icon from R class to ensure it will not break.

GopalVerma1303 commented 10 months ago

Thanks! I will try.

Pankajjajra commented 7 months ago

I have found a solution for this.

just change -

R.drawable.redbox_top_border_background

to

com.facebook.react.R.drawable.redbox_top_border_background