Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capacitor 4.0.0 crashing issue #25

Open
PavelShvets-dev opened this issue Jun 20, 2022 · 17 comments
Open

Capacitor 4.0.0 crashing issue #25

PavelShvets-dev opened this issue Jun 20, 2022 · 17 comments

Comments

@PavelShvets-dev
Copy link

PavelShvets-dev commented Jun 20, 2022

@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

@phiamo
Copy link
Owner

phiamo commented Jun 21, 2022

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

@PavelShvets-dev
Copy link
Author

PavelShvets-dev commented Jun 21, 2022

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..)

@phiamo
Copy link
Owner

phiamo commented Jul 5, 2022

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

@PavelShvets-dev
Copy link
Author

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

Hi! What was the issue?

@phiamo
Copy link
Owner

phiamo commented Jul 30, 2022

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

@hinsxd
Copy link

hinsxd commented Sep 28, 2022

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

@PavelShvets-dev
Copy link
Author

@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.

@hinsxd
Copy link

hinsxd commented Oct 3, 2022

I think it is working

@phiamo
Copy link
Owner

phiamo commented Oct 3, 2022

Is that cap3 backwards compatible?

@phiamo
Copy link
Owner

phiamo commented Oct 11, 2022 via email

@hinsxd
Copy link

hinsxd commented Oct 15, 2022

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 #26 is already trying to address this issue

@emilsaj
Copy link
Contributor

emilsaj commented Jan 6, 2023

@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.

@Marcell90
Copy link

Any update about this?

@emilsaj
Copy link
Contributor

emilsaj commented Feb 23, 2023 via email

@Marcell90
Copy link

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: @.***>

@emilsaj
Copy link
Contributor

emilsaj commented Feb 23, 2023

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.

@phiamo
Copy link
Owner

phiamo commented Feb 27, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants