notifee icon indicating copy to clipboard operation
notifee copied to clipboard

Android API 34: Crash issue

Open maidinhkhoa92 opened this issue 1 year ago • 7 comments

Hi, I found this crash issue when I add this module in a new react-native project (Android API 34).

Unable to start service app.notifee.core.ForegroundService@a933913 with Intent { act=app.notifee.core.ForegroundService.START cmp=com.mywellnessconnect.patient/app.notifee.core.ForegroundService (has extras) }: android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{e093e96 12327:com.mywellnessconnect.patient/u0a352} targetSDK=34

Do you know how to fix this crash? Or if we have a plan to upgrade this library, can you let me know the release time?

maidinhkhoa92 avatar May 29 '24 09:05 maidinhkhoa92

I have the exact same issue. The solution is supposed to be defining the services type in the android manifest inside of the application tag like this

<service
            android:name="app.notifee.core.ForegroundService"
            android:foregroundServiceType="dataSync" />

But when I try to build after doing that I get the issue

Class referenced in the manifest, app.notifee.core.ForegroundService, was not found in the project or the libraries [MissingClass]
              android:name="app.notifee.core.ForegroundService"
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

sgebr01 avatar May 29 '24 17:05 sgebr01

As I investigated, the issue happens on Android API 34 so I made a fork here to fix it. Anyone who wants to have a result. Please follow my change here. Hope the package will be upgraded soon.

https://github.com/maidinhkhoa92/notifee/commit/0aa15c9b2591b9f7644c07c23fa5539345485621

maidinhkhoa92 avatar May 30 '24 03:05 maidinhkhoa92

Same issue on Android 14. @maidinhkhoa92 can you open PR for proposed changes, if they related and solve issue maybe @mikehardy can approve them? Thanks

pronevich avatar Jun 12 '24 21:06 pronevich

The docs shows examples about declaring a foreground service type. You should be able to declare other FGS like dataSync.

If you use expo (managed workflow), I think the best way to edit the manifest is writing a plugin. You should also declare android.permission.FOREGROUND_SERVICE_DATA_SYNC in your app config. You can take a look at these changes: https://github.com/G-Ray/pikatorrent/commit/d044e1c5dac871193053c35872c03fd3192a598e

G-Ray avatar Jun 16 '24 10:06 G-Ray

@pronevich This PR is the same with my changes https://github.com/invertase/notifee/pull/1050

Can you review it?

maidinhkhoa92 avatar Jun 18 '24 05:06 maidinhkhoa92

Google Play is requiring all apps to target 34 from next month and I just ran into this while upgrading our app.

Will this fix be in a forthcoming release?

tjlondon-npauctions avatar Jul 13 '24 17:07 tjlondon-npauctions

Having crash's on production after the update required by google. Any news on this?

Adding the appropriate permissions in the 'AndroidManifest.xml' fixed the crashs for me: <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />

In my case, the app uses background_location, only necessary if you really need. <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

Skullcan avatar Jul 15 '24 13:07 Skullcan

any news on this?

<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />

still make crash on this

<manifest>
    ...
    <!-- For example, with one service type -->
    <service android:name="app.notifee.core.ForegroundService" android:foregroundServiceType="location" />

     <!-- Or, with multiple service types -->
    <service android:name="app.notifee.core.ForegroundService" android:foregroundServiceType="location|camera|microphone" />
</manifest>

still make crash on this

Logan-FE avatar Jul 31 '24 14:07 Logan-FE

@Logan-FE If you need a fixed version until the author updates, you can install my fork in here. https://www.npmjs.com/package/evizi-notifee

maidinhkhoa92 avatar Jul 31 '24 14:07 maidinhkhoa92

+1

amjadbouhouch avatar Aug 05 '24 19:08 amjadbouhouch

In my case, I'm recording audio and I needed to add: <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />

And also check that the POST_NOTIFICATIONS permission has been granted before starting the Notifee service.

This has stopped the app crashing. Be great if the error was handled accordingly though if the required permissions aren't available.

tjlondon-npauctions avatar Aug 05 '24 20:08 tjlondon-npauctions

I still used the old version 4.1.0 Here is a fork for fix the old version. https://www.npmjs.com/package/sx-notifee

zungx avatar Aug 27 '24 02:08 zungx

this library is not maintained anymore?

i see a lot of forks but the PR fixing it not aprooved

fs-dasilva avatar Aug 29 '24 13:08 fs-dasilva