远程调试已终止,原因如下:连接丢失 [英] Remote Debugging has been terminated with reason: Connection lost
本文介绍了远程调试已终止,原因如下:连接丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试查看领域数据库时,出现连接丢失错误.这就是我如何激发Stetho和领域的方法.我仍然收到此错误.我什至放了DeleteDeleteIfMigrationNeeded(true).仍然没用.
I am getting connection lost error, when try to see the realm database. here's how i am initalizing stetho and realm. i am still getting this error. I have even put withDeleteIfMigrationNeeded( true ). still didn't work.
public class ApplicationClass extends Application {
// Database Name...
private static final String DB_NAME = "Cheruvu.realm";
@Override
public void onCreate() {
super.onCreate();
configureRealm();
}
private void configureRealm() {
Realm.init( this );
RealmInspectorModulesProvider realmInspectorModulesProvider = RealmInspectorModulesProvider.builder(this)
.withDeleteIfMigrationNeeded(true)
.build();
Stetho.initialize(
Stetho.newInitializerBuilder( this )
.enableDumpapp( Stetho.defaultDumperPluginsProvider( this ) )
.enableWebKitInspector( realmInspectorModulesProvider )
.build() );
RealmConfiguration config = new RealmConfiguration.Builder()
.name( DB_NAME )
.deleteRealmIfMigrationNeeded()
.encryptionKey( generateSecurityKey() )
.build();
Realm.deleteRealm( config );
Realm.setDefaultConfiguration( config );
}
private byte[] generateSecurityKey() {
ByteBuffer bb = ByteBuffer.wrap( new byte[64] );
bb.putInt( UUID.randomUUID().hashCode() );
return bb.array();
}
@Override
public void onTerminate() {
super.onTerminate();
Realm realm = Realm.getDefaultInstance();
if (!realm.isClosed()) {
Realm.getDefaultInstance().close();
}
}
}
这是我的依赖项:
// stetho for database lookup
implementation "com.uphyca:stetho_realm:2.3.0"
implementation "com.facebook.stetho:stetho:1.5.0"
推荐答案
您缺少该领域的加密密钥.
You are missing the encryption key for the Realm.
String securityKey = generateSecurityKey();
RealmInspectorModulesProvider realmInspectorModulesProvider = RealmInspectorModulesProvider.builder(this)
.withDeleteIfMigrationNeeded(true)
.withEncryptionKey(DB_NAME, securityKey)
.build();
Stetho.initialize(
Stetho.newInitializerBuilder( this )
.enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector( realmInspectorModulesProvider )
.build());
RealmConfiguration config = new RealmConfiguration.Builder()
.name( DB_NAME )
.deleteRealmIfMigrationNeeded()
.encryptionKey(securityKey)
.build();
这篇关于远程调试已终止,原因如下:连接丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文