我在 Java Android 中有以下与 Google 登录相关的代码。
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);
}
}
}
);
我遇到了这个代码检查错误。应用在设备上可以运行,但我想修复这个问题。
/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
我正在使用以下库版本
implementation "androidx.fragment:fragment:1.3.1"