capacitor-plugin-playlist icon indicating copy to clipboard operation
capacitor-plugin-playlist copied to clipboard

Capacitor 4.0.0 crashing issue

Open PavelShvets-dev opened this issue 3 years ago • 17 comments

@phiamo hi! I know it's a little bit early, but current version crashing with new Capacitor 4.0.0 (currently in beta version) on Android 12 (minSdk 31).

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.

The source of crash is PendingIntent inside com.devbrackets.android:playlistcore:2.0.1

To fix crashing you need to upgrage at least two properies inside build.gradle:

  1. Kotlin version ext.kotlin_version = '1.6.0'

  2. PlaylistCore version implementation 'com.devbrackets.android:playlistcore:2.1.0'

I've already tested at my project - works fine

PavelShvets-dev avatar Jun 20 '22 13:06 PavelShvets-dev

can you create a pr please for the READE to cover this?

phiamo avatar Jun 21 '22 19:06 phiamo

can you create a pr please for the READE to cover this?

It's my first pull request on github, i hope i've done everything correct..)

PavelShvets-dev avatar Jun 21 '22 21:06 PavelShvets-dev

I had an issue when trying this, need to check asap

phiamo avatar Jul 05 '22 15:07 phiamo

I had an issue when trying this, need to check asap

Hi! What was the issue?

PavelShvets-dev avatar Jul 05 '22 16:07 PavelShvets-dev

It was with cap 3 and my old setup, switched my dev machine and cap 4 is out, lets see that we can get that in asap

phiamo avatar Jul 30 '22 14:07 phiamo

I tried to follow the stacktrace and used patch-package to with the following diff to make it working with Capacitor 4. I dont know why it works, can someone explain or improve this?

diff --git a/node_modules/capacitor-plugin-playlist/android/build.gradle b/node_modules/capacitor-plugin-playlist/android/build.gradle
index d62c35d..dfdcb19 100644
--- a/node_modules/capacitor-plugin-playlist/android/build.gradle
+++ b/node_modules/capacitor-plugin-playlist/android/build.gradle
@@ -7,7 +7,7 @@ ext {
 }
 
 buildscript {
-    ext.kotlin_version = '1.4.32'
+    ext.kotlin_version = '1.6.0'
     repositories {
         google()
         jcenter()
@@ -69,6 +69,6 @@ dependencies {
     annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
 
     // Playlist support
-    implementation 'com.devbrackets.android:playlistcore:2.0.1'
-
+    implementation 'com.devbrackets.android:playlistcore:2.1.0'
+    implementation 'androidx.work:work-runtime-ktx:2.7.1'
 }
diff --git a/node_modules/capacitor-plugin-playlist/android/src/main/java/org/dwbn/plugins/playlist/notification/PlaylistNotificationProvider.kt b/node_modules/capacitor-plugin-playlist/android/src/main/java/org/dwbn/plugins/playlist/notification/PlaylistNotificationProvider.kt
index eeab8b9..e428cda 100644
--- a/node_modules/capacitor-plugin-playlist/android/src/main/java/org/dwbn/plugins/playlist/notification/PlaylistNotificationProvider.kt
+++ b/node_modules/capacitor-plugin-playlist/android/src/main/java/org/dwbn/plugins/playlist/notification/PlaylistNotificationProvider.kt
@@ -3,6 +3,7 @@ package org.dwbn.plugins.playlist.notification
 import android.annotation.SuppressLint
 import android.app.PendingIntent
 import android.app.PendingIntent.FLAG_UPDATE_CURRENT
+import android.app.PendingIntent.FLAG_IMMUTABLE
 import android.content.Context
 import android.content.Intent
 import com.devbrackets.android.playlistcore.components.notification.DefaultPlaylistNotificationProvider
@@ -19,7 +20,7 @@ class PlaylistNotificationProvider(context: Context?) : DefaultPlaylistNotificat
             intent!!.addFlags(
                     Intent.FLAG_ACTIVITY_REORDER_TO_FRONT or Intent.FLAG_ACTIVITY_SINGLE_TOP)
             return PendingIntent.getActivity(this.context,
-                    0, intent, FLAG_UPDATE_CURRENT
+                    0, intent, FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE
             )
         }
 }
\ No newline at end of file

hinsxd avatar Sep 28 '22 04:09 hinsxd

@hinsxd Hi! Does it works for you or you had some issues still? I believe it's not the only problem, but currently new Capacitor 4 crashes because of lost FLAG_IMMUTABLE inside playlistcore lib. And playlistcore:2.1.0 solved this.

PavelShvets-dev avatar Sep 28 '22 13:09 PavelShvets-dev

I think it is working

hinsxd avatar Oct 03 '22 03:10 hinsxd

Is that cap3 backwards compatible?

phiamo avatar Oct 03 '22 09:10 phiamo

Could you create a pr?

PavelShvets-dev @.***> schrieb am Mo., 20. Juni 2022, 15:12:

@phiamo https://github.com/phiamo hi! I know it's a little bit early, but current version crashing with new Capacitor 4.0.0 (currently in beta version) on Android 12 (minSdk 31).

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.

The source of crash is PendingIntent inside com.devbrackets.android:playlistcore:2.0.1

To fix crashing you need to upgrage at least two properies inside build.gradle:

Kotlin version ext.kotlin_version = '1.6.0' 2.

PlaylistCore version implementation 'com.devbrackets.android:playlistcore:2.1.0'

— Reply to this email directly, view it on GitHub https://github.com/phiamo/capacitor-plugin-playlist/issues/25, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABSTO6QC7VSSBYJN2POUXLVQBU2BANCNFSM5ZI4HANQ . You are receiving this because you were mentioned.Message ID: @.***>

phiamo avatar Oct 11 '22 09:10 phiamo

Could you create a pr? PavelShvets-dev @.> schrieb am Mo., 20. Juni 2022, 15:12: @phiamo https://github.com/phiamo hi! I know it's a little bit early, but current version crashing with new Capacitor 4.0.0 (currently in beta version) on Android 12 (minSdk 31). Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. The source of crash is PendingIntent inside com.devbrackets.android:playlistcore:2.0.1 To fix crashing you need to upgrage at least two properies inside build.gradle: 1. Kotlin version ext.kotlin_version = '1.6.0' 2. PlaylistCore version implementation 'com.devbrackets.android:playlistcore:2.1.0' — Reply to this email directly, view it on GitHub <#25>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABSTO6QC7VSSBYJN2POUXLVQBU2BANCNFSM5ZI4HANQ . You are receiving this because you were mentioned.Message ID: @.>

I think https://github.com/phiamo/capacitor-plugin-playlist/pull/26 is already trying to address this issue

hinsxd avatar Oct 15 '22 16:10 hinsxd

@phiamo I am using Capacitor 3 and have started seeing the app not being able to start after updating (per Google requirements) the target API. This gives this error on app startup when the plugin tries to initialize

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent

I have found the solution for me being the same as @hinsxd has written above. Updated kotlin version, playlistcore version + set the PendingItent Flag explicitely in PlaylistNotificationProvider. For me it is working on Capacitor 3. There is a pull request for updating the dependencies #26. This makes it possible to open the app without crashing.

If the code from @hinsxd is then also applied, we should be good! return PendingIntent.getActivity(this.context, 0, intent, FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE)`

Edit: I have created a pull request #65 for setting the PendingIntent explicitly. Pull request #26 should also be merged for this to work.

emilsaj avatar Jan 06 '23 23:01 emilsaj

Any update about this?

Marcell90 avatar Feb 23 '23 02:02 Marcell90

It's already merges in another pull request. I am using this package for an active cap 4 project.


From: Marcel Alvarez @.> Sent: Thursday, February 23, 2023 3:02:04 AM To: phiamo/capacitor-plugin-playlist @.> Cc: emilsaj @.>; Comment @.> Subject: Re: [phiamo/capacitor-plugin-playlist] Capacitor 4.0.0 crashing issue (Issue #25)

Any update about this?

— Reply to this email directly, view it on GitHubhttps://github.com/phiamo/capacitor-plugin-playlist/issues/25#issuecomment-1441127664, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AX65M6YCYB4SQIWCUXMLFETWY3AJZANCNFSM5ZI4HANQ. You are receiving this because you commented.Message ID: @.***>

emilsaj avatar Feb 23 '23 06:02 emilsaj

I'am unable to install with capacitor 4 due the npm dependency, you know a way to install and use the library with capacitor 4? Thanks

image

It's already merges in another pull request. I am using this package for an active cap 4 project. ________________________________ From: Marcel Alvarez @.> Sent: Thursday, February 23, 2023 3:02:04 AM To: phiamo/capacitor-plugin-playlist @.> Cc: emilsaj @.>; Comment @.> Subject: Re: [phiamo/capacitor-plugin-playlist] Capacitor 4.0.0 crashing issue (Issue #25) Any update about this? — Reply to this email directly, view it on GitHub<#25 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AX65M6YCYB4SQIWCUXMLFETWY3AJZANCNFSM5ZI4HANQ. You are receiving this because you commented.Message ID: @.***>

Marcell90 avatar Feb 23 '23 19:02 Marcell90

The peerdependency for capacitor in package.json is not updated. @phiamo could you maybe make a new major version for this plugin with capacitor ^4.y.z as Peer dependency instead of capacitor 3? I have done it on my fork already for my own usage.

emilsaj avatar Feb 23 '23 19:02 emilsaj

Hi and sorry, I am currently not able to test changes and was afraid that it breaks bc . I think you guys are using it in a current version. In finally found the button and added @emilsaj as a collaborator. Please @emilsaj feel free to merge and create releases I am very thankful for all the contributions!

emilsaj @.***> schrieb am Do., 23. Feb. 2023, 20:54:

The peerdependency for capacitor in package.json is not updated. @phiamo https://github.com/phiamo could you maybe make a new major version for this plugin with capacitor ^4.y.z as Peer dependency instead of capacitor 3? I have done it on my fork already for my own usage.

— Reply to this email directly, view it on GitHub https://github.com/phiamo/capacitor-plugin-playlist/issues/25#issuecomment-1442350600, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABSTO7UBOSY6XVIK5JTBODWY656BANCNFSM5ZI4HANQ . You are receiving this because you were mentioned.Message ID: @.***>

phiamo avatar Feb 27 '23 19:02 phiamo

with the new versions this was tested to not to happen

phiamo avatar Jul 26 '24 21:07 phiamo