每当我尝试在 Android 上匿名登录时使用
appId = AppID.getInstance();
appId.initialize(this,tenantId, region);
appId.signinAnonymously(this, new AuthorizationListener() {
@Override
public void onAuthorizationFailure(AuthorizationException exception) {
}
@Override
public void onAuthorizationSuccess(AccessToken accessToken, IdentityToken identityToken, RefreshToken refreshToken) {
}
@Override
public void onAuthorizationCanceled() {
}
});
我在启动时收到此错误:
FATAL EXCEPTION: OkHttp Dispatcher
Process: com.watizit, PID: 9411
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at com.ibm.cloud.appid.android.internal.authorizationmanager.AuthorizationManager$5.onSuccess(AuthorizationManager.java:341)
at com.ibm.mobilefirstplatform.clientsdk.android.core.internal.BaseRequest$2.onResponse(BaseRequest.java:771)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:203)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:929)
当我删除 signinAnonymously 块时,它不再崩溃。我怀疑回调 + okhttp 存在问题,但我不知道到底是什么。知道如何解决吗?谢谢
这是我的依赖项的定义方式(默认):
dependencies {
implementation 'com.github.ibm-cloud-security:appid-clientsdk-android:6.+'
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
我只添加了这一行: implementation 'com.github.ibm-cloud-security:appid-clientsdk-android:6.+'