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

Android facebook-login library 11.2.0 crashes Android 12 - Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE #997

Closed
5 tasks done
juliusspencer opened this issue Sep 7, 2021 · 12 comments

Comments

@juliusspencer
Copy link

Checklist before submitting a bug report

Java version

11.0.10+9

Android version

API 31, Android 12

Android SDK version

11.2.0

Installation platform & version

Gradle

Package

Login

Goals

Handling a callback in onActivityResult from a successful login.

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
	super.onActivityResult(requestCode, resultCode, data)
	// Pass the activity result back to the Facebook SDK
	facebookCallbackManager.onActivityResult(requestCode, resultCode, data)
}

Expected results

Receive the response in a FacebookCallback.

              LoginManager.getInstance().registerCallback(
		facebookCallbackManager,
		object : FacebookCallback<LoginResult> {
			override fun onSuccess(loginResult: LoginResult) {
                                  // here
			}

			override fun onCancel() {
                                  // or here
			}

			override fun onError(error: FacebookException) {
                                  // or here
			}
		})

Actual results

Crash:

 Caused by: java.lang.IllegalArgumentException: my.app.id: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
 Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
    at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
    at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
    at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
    at com.facebook.AccessTokenManager.setTokenExpirationBroadcastAlarm(AccessTokenManager.kt:121)
    at com.facebook.AccessTokenManager.setCurrentAccessToken(AccessTokenManager.kt:94)
    at com.facebook.AccessTokenManager.setCurrentAccessToken(AccessTokenManager.kt:47)
    at com.facebook.AccessToken$Companion.setCurrentAccessToken(AccessToken.kt:428)
    at com.facebook.AccessToken.setCurrentAccessToken(Unknown Source:2)
    at com.facebook.login.LoginManager.finishLogin(LoginManager.java:894)
    at com.facebook.login.LoginManager.onActivityResult(LoginManager.java:247)
    at com.facebook.login.LoginManager$1.onActivityResult(LoginManager.java:186)

Steps to reproduce

In your build.gradle target 31:

android {
    compileSdkVersion 31

    defaultConfig {
        applicationId "my.app.id"
        minSdkVersion 23
        targetSdkVersion 31

Perform a log in action:

	val loginManager = LoginManager.getInstance()
	loginManager.logInWithReadPermissions(this, listOf("email", "public_profile"))

Code samples & details

// onActivityResult
	override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
		super.onActivityResult(requestCode, resultCode, data)
		// Pass the activity result back to the Facebook SDK
		facebookCallbackManager.onActivityResult(requestCode, resultCode, data)
	}

// initialise callback

		facebookCallbackManager = CallbackManager.Factory.create()
		LoginManager.getInstance().registerCallback(
			facebookCallbackManager,
			object : FacebookCallback<LoginResult> {
				override fun onSuccess(loginResult: LoginResult) {
				}

				override fun onCancel() {
				}

				override fun onError(error: FacebookException) {
				}
			})

// perform sign in
				val loginManager = LoginManager.getInstance()
				loginManager.logInWithReadPermissions(this, listOf("email", "public_profile"))
@linmx0130
Copy link

Hi @juliusspencer, thanks for raising this issue! The fix is merged into the current main branch as 1b8c151. It will be released soon in Facebook Android SDK v11.3.0.

@prateekcode
Copy link

Can you please let me know when this release will be out? I'm still getting this issue.

@hoangvuanhdevelopervn
Copy link

Can you please let me know when this release will be out? I'm still getting this issue.

Me too, it's still erro

@hoangvuanh761993
Copy link

It's still an error on Android 12

@sobhanaKR
Copy link

Is it fixed now ?

@linmx0130
Copy link

Hi all! This problem should already be fixed in the latest Facebook Android SDK. If you still have the issue, could you share the crash tracelog and the SDK version you're using for us to determine the problem?

@amsheerS
Copy link

implementation 'com.facebook.android:facebook-android-sdk:12.3.0'

This one solved the issue.

@heeveG
Copy link

heeveG commented Feb 2, 2022

@linmx0130
Hi, app still crashes

Here is the tracelog:

Type
exception.class.missing._Unknown_

exception.class.missing._Unknown_: Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
  at android.app.PendingIntent.checkFlags (PendingIntent.java:382)
  at android.app.PendingIntent.getBroadcastAsUser (PendingIntent.java:673)
  at android.app.PendingIntent.getBroadcast (PendingIntent.java:660)
  at com.facebook.AccessTokenManager.setTokenExpirationBroadcastAlarm (AccessTokenManager.kt:121)
  at com.facebook.AccessTokenManager.setCurrentAccessToken (AccessTokenManager.kt:94)
  at com.facebook.AccessTokenManager.setCurrentAccessToken (AccessTokenManager.kt:47)
  at com.facebook.AccessTokenManager$refreshCurrentAccessTokenImpl$1.onBatchCompleted (AccessTokenManager.kt:256)
  at com.facebook.GraphRequest$Companion$runCallbacks$runnable$1.run (GraphRequest.kt:1033)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:226)
  at android.os.Looper.loop (Looper.java:313)
  at android.app.ActivityThread.main (ActivityThread.java:8582)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:563)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1133)

We are using 12.2 SDK version

@amsheerS
Copy link

amsheerS commented Feb 2, 2022

@linmx0130 Hi, app still crashes

Here is the tracelog:

Type
exception.class.missing._Unknown_

exception.class.missing._Unknown_: Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
  at android.app.PendingIntent.checkFlags (PendingIntent.java:382)
  at android.app.PendingIntent.getBroadcastAsUser (PendingIntent.java:673)
  at android.app.PendingIntent.getBroadcast (PendingIntent.java:660)
  at com.facebook.AccessTokenManager.setTokenExpirationBroadcastAlarm (AccessTokenManager.kt:121)
  at com.facebook.AccessTokenManager.setCurrentAccessToken (AccessTokenManager.kt:94)
  at com.facebook.AccessTokenManager.setCurrentAccessToken (AccessTokenManager.kt:47)
  at com.facebook.AccessTokenManager$refreshCurrentAccessTokenImpl$1.onBatchCompleted (AccessTokenManager.kt:256)
  at com.facebook.GraphRequest$Companion$runCallbacks$runnable$1.run (GraphRequest.kt:1033)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:226)
  at android.os.Looper.loop (Looper.java:313)
  at android.app.ActivityThread.main (ActivityThread.java:8582)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:563)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1133)

We are using 12.2 SDK version

implementation 'com.facebook.android:facebook-android-sdk:12.3.0'

Please try this

@heeveG
Copy link

heeveG commented Feb 2, 2022

@linmx0130 Hi, app still crashes
Here is the tracelog:

Type
exception.class.missing._Unknown_

exception.class.missing._Unknown_: Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
  at android.app.PendingIntent.checkFlags (PendingIntent.java:382)
  at android.app.PendingIntent.getBroadcastAsUser (PendingIntent.java:673)
  at android.app.PendingIntent.getBroadcast (PendingIntent.java:660)
  at com.facebook.AccessTokenManager.setTokenExpirationBroadcastAlarm (AccessTokenManager.kt:121)
  at com.facebook.AccessTokenManager.setCurrentAccessToken (AccessTokenManager.kt:94)
  at com.facebook.AccessTokenManager.setCurrentAccessToken (AccessTokenManager.kt:47)
  at com.facebook.AccessTokenManager$refreshCurrentAccessTokenImpl$1.onBatchCompleted (AccessTokenManager.kt:256)
  at com.facebook.GraphRequest$Companion$runCallbacks$runnable$1.run (GraphRequest.kt:1033)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:226)
  at android.os.Looper.loop (Looper.java:313)
  at android.app.ActivityThread.main (ActivityThread.java:8582)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:563)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1133)

We are using 12.2 SDK version

implementation 'com.facebook.android:facebook-android-sdk:12.3.0'

Please try this

Thanks for your reply!
Are you sure the issue was attempted to be fixed exactly in 12.3.0 and not before (we use the previous version 12.2.0)? As I see from the commit history, Fix PendingIntent vulnerability commit was made on 7 Aug 2021.

Just making sure, because the update process on our project takes quite a while.

@linmx0130
Copy link

Hi @heeveG! Please double confirm that you're using the latest SDK.
According to your tracelog, the crash happens at AccessTokenManager.kt:121. However, Fix PendingIntent vulnerability commit modify the pending intent creation calls, so the call should happens at line 123 or line 125.

As your tracelog shows, the SDK creates the pending intent at line 121, which means that it doesn't adopt the patch.

@ShahrukhBT
Copy link

ShahrukhBT commented Mar 10, 2023

Is there any another way to implement the facebook login natively in both android(Xamarin) and ios(Xamarin)?

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

10 participants