parse-community / Parse-SDK-Android

The Android SDK for Parse Platform
https://parseplatform.org/
Other
1.88k stars 739 forks source link

Cloud function fails on Android 12 #1145

Closed buzmax closed 2 years ago

buzmax commented 2 years ago

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[bot] commented 2 years ago

Thanks for opening this issue!

mtrezza commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

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.

mman commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

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

mman commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

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

SantosVithor commented 2 years ago

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 commented 2 years ago

Thanks, please let us know if you discover more.

mtrezza commented 2 years ago

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:

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

https://github.com/parse-community/Parse-SDK-Android/blob/7d0faa38bf3ccc85b715dc61965d5b82103c19a4/parse/src/main/java/com/parse/ParsePushBroadcastReceiver.java#L417-L420

Added in version 3.0.0 via https://github.com/parse-community/Parse-SDK-Android/pull/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.