簡體   English   中英

找不到領域文件ERROR Android

[英]Realm File not found ERROR Android

所有這些時間,我一直在考慮在創建RealmConfiguration時創建領域文件。 但是今天,當我觀察到時,使用Realm.getDefaultInstance()將數據寫入該文件時便創建了該文件。 我們在我們的應用程序中具有登錄/注銷功能。 我在Application類中定義了領域配置。

val realmConfiguration = RealmConfiguration.Builder(this)
                .schemaVersion(1)
                .migration(RealmMigrationClass())
                .build()

Realm.setDefaultConfiguration(realmConfiguration)

登錄期間,我從用戶那里獲取所有詳細信息,並從后端獲取與用戶相關的信息,並將其存儲在領域中。

注銷期間,我刪除了所有與應用程序相關的數據(即,我也從getFilesDir()中刪除了文件。 因此,在注銷期間,領域文件將被刪除。

在重新登錄期間,將調用Login活動(MainApp中的realmConfiguration不受干擾),並且再次獲取用戶詳細信息並將其保存在realm中。

我們已將社交登錄信息集成到應用程序中。 對於Google登錄,除了登錄活動已初始化mGoogleApiClient之外,我們無法退出其他地方。 因此,在注銷期間我們沒有注銷google用戶,而是在下一個登錄請求期間注銷了該用戶。

googleLogin.onClick {

            if(mGoogleApiClient?.isConnected ?:false){
                Auth.GoogleSignInApi.signOut(mGoogleApiClient)
                val signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
                startActivityForResult(signInIntent, RC_GET_TOKEN)
            }else{
                val signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
                startActivityForResult(signInIntent, RC_GET_TOKEN)
            }
        }

我們確實支持自定義登錄,注銷。 我們確實有Twitter登錄/注銷,除了Google之外,還有Facebook登錄/注銷。 但是,僅谷歌登錄一個人會導致重新登錄時出現問題(即用戶使用包括谷歌登錄在內的任何模式成功登錄應用程序。第一次運行完全正常。但是,如果用戶退出並嘗試通過谷歌登錄,則失敗。但是與其他人重新登錄自定義,Facebook和Twitter模式可以正常運行)。 登錄后,嘗試將用戶詳細信息寫入領域時,它抱怨領域文件不存在,並顯示發生了意外錯誤。 發生意外錯誤后,再次使用Google登錄即可正確創建領域。

注銷代碼如下。

cacheDir.deleteRecursively()
        filesDir.deleteRecursively()

        AppUtilityFunctions.facebookSignout()
        AppUtilityFunctions.twitterSignout(this)

        //After logging out launch welcome page
        val intent = Intent(this, WelcomeActivity::class.java)
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or
                Intent.FLAG_ACTIVITY_CLEAR_TASK or
                Intent.FLAG_ACTIVITY_TASK_ON_HOME)
        startActivity(intent)


06-13 22:07:29.634 11246-11246/? D/REALM: jni: ThrowingException 5, , .
06-13 22:07:29.634 11246-11246/? D/REALM: Exception has been throw: File not found: .
06-13 22:07:29.634 11246-11246/? D/AndroidRuntime: Shutting down VM
06-13 22:07:29.634 11246-11246/? W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x9cccdb20)
06-13 22:07:29.634 11246-11272/? E/CrashlyticsCore: Tried to write a fatal exception while no session was open.
06-13 22:07:29.644 11246-11246/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.clinicloud.app.dev, PID: 11246
                                                   io.realm.exceptions.RealmIOException: File not found: .
                                                       at io.realm.internal.SharedGroup.createNativeWithImplicitTransactions(Native Method)
                                                       at io.realm.internal.SharedGroup.<init>(SharedGroup.java:67)
                                                       at io.realm.internal.r.<init>(SharedGroupManager.java:47)
                                                       at io.realm.a.<init>(BaseRealm.java:76)
                                                       at io.realm.o.<init>(Realm.java:126)

任何人都知道發生了什么事嗎?

我通過在Google登錄期間刪除Auth.GoogleSignInApi.signOut(mGoogleApiClient)來解決此問題,並在我從Google收集了與用戶相關的所有信息后放入了退出代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM