-
Notifications
You must be signed in to change notification settings - Fork 125
Description
Before opening, please confirm:
- I have searched for duplicate or closed issues and discussions.
Language and Async Model
RxJava
Amplify Categories
Authentication
Gradle script dependencies
dependencies.add("implementation", libs.amplify.api)
dependencies.add("implementation", libs.amplify.auth)
dependencies.add("implementation", libs.amplify.core)
dependencies.add("implementation", libs.amplify.pinpoint)
dependencies.add("implementation", libs.amplify.rxbindings)
dependencies.add("implementation", libs.amplify.storage)
Environment information
------------------------------------------------------------
Gradle 8.13
------------------------------------------------------------
Build time: 2025-02-25 09:22:14 UTC
Revision: 073314332697ba45c16c0a0ce1891fa6794179ff
Kotlin: 2.0.21
Groovy: 3.0.22
Ant: Apache Ant(TM) version 1.10.15 compiled on August 25 2024
Launcher JVM: 21.0.8 (JetBrains s.r.o. 21.0.8+-14196175-b1038.72)
Daemon JVM: D:\Programs\Studio\jbr (no JDK specified, using current Java home)
OS: Windows 11 10.0 amd64
Please include any relevant guides or documentation you're referencing
No response
Describe the bug
Because of that huge issue with 2.30.2, 2.30.3, when I update to 2.30.4 I did a workaround to sign out the users with a bad state:
- when the user will arrive in the Mainscreen of app I am doing a check comparing the local user with Amplify.Auth.getCurrentUser and I check auth?.userId.
App Flow:
- In Application I initialize the Amplify SDK using RxAmplify. (remember this is important), if something appear a error in Splashscreen I show it, so the user will not open the Mainscreen of the app.
- If init was fine, appear Splashscreen, then Mainscreen where I am doing that addional check.
- On this addional check instead to use RxAmplify.Auth.currentUser, I am using Amplify.Auth.getCurrentUser.
And on step 3 I get this error, but not all the time:
Fatal Exception: java.lang.IllegalStateException: Tried to get a plugin but that plugin was not present. Check if the plugin was added originally or perhaps was already removed.
at com.amplifyframework.core.category.Category.getPluginIfConfiguredOrThrow(Category.java:257)
at com.amplifyframework.core.category.Category.getSelectedPlugin(Category.java:252)
at com.amplifyframework.auth.AuthCategory.getCurrentUser(AuthCategory.java:381)
at com.bfan.sso.logic.services.amplify.state.AmplifyState$register$1.invokeSuspend(AmplifyState.kt:35)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:124)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:820)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)
This is my class where I am doing that check: at com.bfan.sso.logic.services.amplify.state.AmplifyState.
Base on your documentation there should not be a problem if I am using RxAmplify and Amplify, but I remember in the past I created a similar issue with RxAmplify.Analytics vs Amplify.Analytics and there was a real issue, you can search in history.
#2943
Please help me with this issue, the app is live in store and I have no idea what is wrong.
Reproduction steps (if applicable)
No response
Code Snippet
// Put your code below this line.
Amplify init:
private Completable initAmplify() {
return Completable.fromAction(() -> {
if (amplifyConfigured.get()) return;
synchronized (amplifyConfigured) {
if (amplifyConfigured.get()) return;
AWSApiPlugin apiPlugin = AWSApiPlugin.builder()
.configureClient("-----", okHttpBuilder -> okHttpBuilder.addInterceptor(chain -> {
Request originalRequest = chain.request();
String modifiedUrl = originalRequest.url().toString()
.replace("+", "%2B")
.replace(";", "%3B")
.replace("#", "%23");
Request modifiedRequest = originalRequest.newBuilder()
.url(modifiedUrl)
.build();
LogUtils.i("RxAmplify URL: " + modifiedRequest.url().url());
return chain.proceed(modifiedRequest);
})).configureClient("-----", okHttpBuilder -> okHttpBuilder.addInterceptor(chain -> {
Request originalRequest = chain.request();
String modifiedUrl = originalRequest.url().toString()
.replace("+", "%2B")
.replace(";", "%3B")
.replace("#", "%23");
Request modifiedRequest = originalRequest.newBuilder()
.url(modifiedUrl)
.build();
LogUtils.i("RxAmplify URL: " + modifiedRequest.url().url());
return chain.proceed(modifiedRequest);
})).configureClient("-----", okHttpBuilder -> okHttpBuilder.addInterceptor(chain -> {
Request originalRequest = chain.request();
String modifiedUrl = originalRequest.url().toString()
.replace("+", "%2B")
.replace(";", "%3B")
.replace("#", "%23");
Request modifiedRequest = originalRequest.newBuilder()
.url(modifiedUrl)
.build();
LogUtils.i("RxAmplify URL: " + modifiedRequest.url().url());
return chain.proceed(modifiedRequest);
})).build();
apiPlugin.configure(AmplifyConfig.Companion.getInstance().getApiConfiguration(), AppApplication.Companion.getInstance());
RxAmplify.addPlugin(apiPlugin);
RxAmplify.addPlugin(new AWSCognitoAuthPlugin());
RxAmplify.addPlugin(new AWSS3StoragePlugin());
RxAmplify.addPlugin(new AWSPinpointAnalyticsPlugin());
AmplifyConfiguration configuration = AmplifyConfiguration.builder(AmplifyConfig.Companion.getInstance().getAWSConfiguration())
.devMenuEnabled(BuildConfig.DEBUG)
.build();
RxAmplify.configure(configuration, AppApplication.Companion.getInstance());
amplifyConfigured.set(true);
}
});
}
State check:
private val checkTyp = CheckType.USER
fun register(currentUser: User?, callback: UiCallback) {
owner.lifecycleScope.launch(Dispatchers.IO) {
if (checkTyp == CheckType.USER_ATTRIBUTES) {
Amplify.Auth.fetchUserAttributes({ attrs ->
owner.lifecycleScope.launch(Dispatchers.Main) {
handlerSuccess(currentUser, attrs, callback)
}
}, { _ ->
owner.lifecycleScope.launch(Dispatchers.Main) {
handlerError(currentUser, callback)
}
})
} else {
Amplify.Auth.getCurrentUser({ value ->
owner.lifecycleScope.launch(Dispatchers.Main) {
handlerSuccess(currentUser, value, callback)
}
}) {
owner.lifecycleScope.launch(Dispatchers.Main) {
handlerError(currentUser, callback)
}
}
}
}
}Log output
// Put your logs below this line
Configuration File
No response
GraphQL Schema
// Put your schema below this line
Additional information and screenshots
No response