Skip to content

Cloud function fails on Android 12 #1145

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

Closed
buzmax opened this issue Nov 25, 2021 · 15 comments
Closed

Cloud function fails on Android 12 #1145

buzmax opened this issue Nov 25, 2021 · 15 comments
Labels
type:question Support or code-level question

Comments

@buzmax
Copy link

buzmax commented Nov 25, 2021

When I try to call cloud function (ParseCloud.callFunction...) on android 12 I get this exception:

❌ java.lang.IllegalArgumentException: com.onstruct.android.uat: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.

@parse-github-assistant
Copy link

parse-github-assistant bot commented Nov 25, 2021

Thanks for opening this issue!

  • ❌ Please edit your post and use the provided template when creating a new issue. This helps everyone to understand your post better and asks for essential information to quicker review the issue.

@mtrezza mtrezza added state:needs-investigation type:bug Impaired feature or lacking behavior that is likely assumed labels Nov 25, 2021
@mtrezza
Copy link
Member

mtrezza commented Nov 25, 2021

@buzmax Please update your post using the issue template.

@L3K0V Side note, would it make sense / be possible to add various Android CI environments, like we run our Parse Server CI in various Node.js environments?

@azlekov
Copy link
Contributor

azlekov commented Nov 25, 2021

Make sense @mtrezza, but some tests must be added/updated.
I hope @buzmax uses and old version, as FLAG_IMMUTABLE was introduced what, like week ago...

@azlekov
Copy link
Contributor

azlekov commented Nov 30, 2021

@buzmax can you confirm that this happens on the latest version of the SDK?

Can you share a bit more detailed log, not sure how ParseCloud is related with pending intents.

@mtrezza mtrezza pinned this issue Apr 27, 2022
@mtrezza
Copy link
Member

mtrezza commented Apr 27, 2022

I've pinned this issue; in case there is really an issue with Android 12, we need to address this urgently.

There seem to be a lot of similar issues reported regarding other SDKs. As I understand, the issue only occurs when targeting Android 12, which will become mandatory by August 2022 on the Google Play Store.

@mtrezza mtrezza added bounty:$100 Bounty applies for fixing this issue (Parse Bounty Program) and removed state:needs-investigation labels Apr 27, 2022
@mtrezza mtrezza changed the title Calling cloud function on Android 12 Cloud function fails on Android 12 Apr 27, 2022
@mman
Copy link

mman commented Apr 27, 2022

@buzmax We need more details. The error you are showing does not relate at all to calling cloud functions via Parse SDK. Please post a stack trace or snippet of code what you are doing around ParseCloud.callFunction and we can investigate.

@mtrezza
Copy link
Member

mtrezza commented Apr 27, 2022

In case @buzmax doesn't respond, I think the way to try to replicate this is to have an Android app target Android 12 and try using the Parse SDK like calling a Cloud Code function.

@mman
Copy link

mman commented Apr 28, 2022

@mtrezza I have android sdk in production using cloud functions, no problems on any android

@mman
Copy link

mman commented Apr 28, 2022

@mtrezza To be precise I am now targeting API level 31 (Android 12) with minSdkVersion stuck on API level 19 (Android 4.4), thus still using Parse-SDK-Android version 2.1.0. And can not replicate the issue in any way.

    compileSdkVersion=31
    targetSdkVersion=31
    minSdkVersion=19

Need more data for this.

@mtrezza
Copy link
Member

mtrezza commented Apr 28, 2022

Thanks @mman that's a good indication at least that you cannot replicate. I also found this comment:

When targeting Android S+, some internal androidx libraries still use an older version of WorkManager which do not use FLAG_IMMUTABLE or FLAG_MUTABLE flag.
As a workaround,
simply add the latest version of the WorkManager dependency in your app's build.gradle & sync the project.

I guess we can leave this open for some more weeks, and if no-one responds or confirms this we can close this issue.

@mman
Copy link

mman commented Apr 28, 2022

@mtrezza I will do some more investigation next week when I get a chance, but for now I think this is unrelated to Parse Android SDK.

@mtrezza
Copy link
Member

mtrezza commented Apr 28, 2022

I guess one point of investigation could be to look whether the SDKs actually uses any PendingIntent.

@SantosVithor
Copy link

I'm in an old project that was using these libs for parse:

//Parse
    implementation 'com.parse:parse-android:1.17.3'
    implementation 'com.parse:parse-fcm-android:1.17.3'
    implementation "com.github.yongjhih.RxParse:rxparse2:2.1.0"

But because I had to update to sdk 31, I had this issue that @buzmax pointed out. Solved after updating gradle, kotlin and other stuff. But when I receive a push notification, the app crashes (on the super line):

override fun onPushReceive(context: Context, intent: Intent) {
        super.onPushReceive(context, intent)
        parseIncomingIntent(intent, context, false)
}

I don't understand quite yet these "advanced" concepts, but, from where I'm standing, it looks like those old libs use pending intents somewhere. Right now, I'm struggling to properly update without causing this crash. One other thing is that I changed my old libs for the "new" ones:

    implementation "com.github.parse-community.Parse-SDK-Android:parse:2.0.6"
    implementation "com.github.parse-community.Parse-SDK-Android:fcm:2.0.6"
    implementation "com.github.parse-community.Parse-SDK-Android:rxjava:2.0.6"
    implementation "com.github.parse-community.Parse-SDK-Android:ktx:2.0.6"
    implementation "com.github.parse-community.Parse-SDK-Android:coroutines:2.0.6"

And that solved this pending intent problem, but I'm having some other bugs related to some old custom code related to ParseObsevalbe.callFunction not existing in these new libs.

I thought that the problem seemed similar to mine, so I wanted to make it clear. I guess that's why this problem is in the Parse SDK issue list.

@mtrezza
Copy link
Member

mtrezza commented May 6, 2022

Thanks, please let us know if you discover more.

@mtrezza
Copy link
Member

mtrezza commented May 21, 2022

I tried it out with an old Parse Android SDK 1.24.2, targetSdkVersion 31, compileSdkVersion 31 on Android API 31 and was not able to reproduce the issue even with that old SDK version. I was able to reproduce this however by creating a PendingIntent without any mutability flag.

I think to investigate this any further we need a full stack trace instead of just the error message. So we can know whether this comes from custom code or the Parse Android SDK, and from where inside the SDK exactly.

I am closing this for now until someone can:

  • reproduce this with the latest version of the Parse Android SDK, and
  • provide a stack trace that verifies that this is caused inside the SDK

The ParsePushBroadcastReciever already seems to account for the required mutability flag:

int pendingIntentFlags =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
? PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE
: PendingIntent.FLAG_UPDATE_CURRENT;

Added in version 3.0.0 via #1139.

Searching for PendingIntent across the whole project only find occurrences in the ParsePushBroadcastReciever.

I'll keep this pinned for visibility a little longer, in case others experience a similar issue.

@mtrezza mtrezza closed this as completed May 21, 2022
@mtrezza mtrezza unpinned this issue May 21, 2022
@mtrezza mtrezza added type:question Support or code-level question and removed type:bug Impaired feature or lacking behavior that is likely assumed bounty:$100 Bounty applies for fixing this issue (Parse Bounty Program) labels May 21, 2022
@mtrezza mtrezza pinned this issue May 21, 2022
@mtrezza mtrezza unpinned this issue May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests

5 participants