Error: Upgrade Fragment version to at least 1.3.0. [InvalidFragmentVersionForActivityResult]

Viewed 1743

I have the following login with google code in java android.

private void signIn() {
        Intent signInIntent = mGoogleSignInClient.getSignInIntent();
        someActivityResultLauncher.launch(signInIntent);
}

ActivityResultLauncher<Intent> someActivityResultLauncher = registerForActivityResult(
        new ActivityResultContracts.StartActivityForResult(),
        new ActivityResultCallback<ActivityResult>() {
            @Override
            public void onActivityResult(ActivityResult result) {
                if (result.getResultCode() == Activity.RESULT_OK) {
                    Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(result.getData());
                    handleSignInResult(task);
                }
            }
        }
);

And I get this linting error. App does run on device. But I would like to fix this issue.

/home/runner/work/etu-android/etu-android/app/src/main/java/com/encycode/etus/Login.java:151: Error: Upgrade Fragment version to at least 1.3.0. [InvalidFragmentVersionForActivityResult]
    ActivityResultLauncher<Intent> someActivityResultLauncher = registerForActivityResult(
                                                                ^

   Explanation for issues of type "InvalidFragmentVersionForActivityResult":
   In order to use the ActivityResult APIs you must upgrade your              
     Fragment version to 1.3.0. Previous versions of FragmentActivity         
          failed to call super.onRequestPermissionsResult() and used invalid
   request codes

I am using following library version

implementation "androidx.fragment:fragment:1.3.1"
2 Answers

This is a known issue which is already fixed for the next version. You can either wait for that release to come out or suppress the warning.

Edit: Fragment 1.3.2 has been released and states:

Fragment now depends on Activity 1.2.2, fixing an issue with Activity’s InvalidFragmentVersionForActivityResult lint check when using Fragment 1.3.1 or higher.

So you should upgrade to Fragment 1.3.2.

Related