错误:将Fragment版本升级到至少1.3.0。[InvalidFragmentVersionForActivityResult]
我在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);
}
}
}
);
我得到这个 linting 错误。应用程序确实在设备上运行。但我想解决这个问题。
/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"
回答
这是一个已知问题,已在下一版本中修复。您可以等待该版本发布或取消警告。
编辑:片段 1.3.2已发布并声明:
Fragment 现在依赖于Activity 1.2.2,修复了
InvalidFragmentVersionForActivityResult使用 Fragment 1.3.1 或更高版本时Activity 的lint 检查问题。
所以你应该升级到 Fragment 1.3.2。
- I am still getting lint error, this is a bit old project written in Java and I already added `androidx.activity:activity-ktx:1.3.0-alpha07` and using `androidx.fragment:fragment-ktx:1.3.3` working with AS Arctic Fox Canary 15
THE END
二维码