android – java.lang.NoClassDefFoundError:失败的解析:Lio / realm / internal / SharedRealm $Durability

前端之家收集整理的这篇文章主要介绍了android – java.lang.NoClassDefFoundError:失败的解析:Lio / realm / internal / SharedRealm $Durability前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用Realm创建一个演示应用程序,使用Facebook的stetho浏览default.realm.我每次尝试使用chrome:// inspect>在谷歌浏览器上打开default.realm时出现此错误资源> Web sql> default.realm

这就是我所做的.

的build.gradle

repositories {
    maven {
        url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
    }
}

dependencies {
    ...
    compile 'com.uphyca:stetho_realm:2.0.0'
    compile 'com.facebook.stetho:stetho:1.4.1'
}

我的应用类

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder(this).build();
        Realm.setDefaultConfiguration(realmConfiguration);

        Stetho.initialize(
                Stetho.newInitializerBuilder(this)
                        .enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
                        .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this))
                        .build());
    }
}

应用程序崩溃时出现此错误

E/AndroidRuntime: FATAL EXCEPTION: StethoWorker-main-304
                  Process: example.com.demoapp,PID: 12830
                  java.lang.NoClassDefFoundError: Failed resolution of: Lio/realm/internal/SharedRealm$Durability;
                      at com.uphyca.stetho_realm.RealmPeerManager.openSharedRealm(RealmPeerManager.java:136)
                      at com.uphyca.stetho_realm.RealmPeerManager.openSharedRealm(RealmPeerManager.java:128)
                      at com.uphyca.stetho_realm.RealmPeerManager.getDatabaseTableNames(RealmPeerManager.java:55)
                      at com.uphyca.stetho_realm.Database.getDatabaseTableNames(Database.java:124)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.facebook.stetho.inspector.MethodDispatcher$MethodDispatchHelper.invoke(MethodDispatcher.java:96)
                      at com.facebook.stetho.inspector.MethodDispatcher.dispatch(MethodDispatcher.java:67)
                      at com.facebook.stetho.inspector.ChromeDevtoolsServer.handleRemoteRequest(ChromeDevtoolsServer.java:129)
                      at com.facebook.stetho.inspector.ChromeDevtoolsServer.handleRemoteMessage(ChromeDevtoolsServer.java:111)
                      at com.facebook.stetho.inspector.ChromeDevtoolsServer.onMessage(ChromeDevtoolsServer.java:87)
                      at com.facebook.stetho.websocket.WebSocketSession$1.handleTextFrame(WebSocketSession.java:176)
                      at com.facebook.stetho.websocket.WebSocketSession$1.onCompleteFrame(WebSocketSession.java:136)
                      at com.facebook.stetho.websocket.ReadHandler.readLoop(ReadHandler.java:44)
                      at com.facebook.stetho.websocket.WebSocketSession.handle(WebSocketSession.java:45)
                      at com.facebook.stetho.websocket.WebSocketHandler.doUpgrade(WebSocketHandler.java:117)
                      at com.facebook.stetho.websocket.WebSocketHandler.handleRequest(WebSocketHandler.java:83)
                      at com.facebook.stetho.server.http.LightHttpServer.dispatchToHandler(LightHttpServer.java:84)
                      at com.facebook.stetho.server.http.LightHttpServer.serve(LightHttpServer.java:61)
                      at com.facebook.stetho.inspector.DevtoolsSocketHandler.onAccepted(DevtoolsSocketHandler.java:52)
                      at com.facebook.stetho.server.ProtocolDetectingSocketHandler.onSecured(ProtocolDetectingSocketHandler.java:63)
                      at com.facebook.stetho.server.SecureSocketHandler.onAccepted(SecureSocketHandler.java:33)
                      at com.facebook.stetho.server.LazySocketHandler.onAccepted(LazySocketHandler.java:36)
                      at com.facebook.stetho.server.LocalSocketServer$WorkerThread.run(LocalSocketServer.java:167)
                   Caused by: java.lang.ClassNotFoundException: Didn't find class "io.realm.internal.SharedRealm$Durability" on path: DexPathList[[dex file "/data/data/example.com.demoapp/files/instant-run/dex/slice-support-annotations-24.2.1_fe2fc8f98c9647365914a4e0809de4cf3bdd5d0f-classes.dex",dex file "/data/data/example.com.demoapp/files/instant-run/dex/slice-slice_9-classes.dex",dex file "/data/data/example.com.demoapp/files/instant-run/dex/slice-slice_8-classes.dex",dex file "/data/data/example.com.demoapp/files/instant-run/dex/slice-slice_7-classes.dex",dex file "/data/data/example.com.demoapp/files/instant-run/dex/slice-slice_6-classes.dex",dex file "/data/data/example.com.demoapp/files/instant-run/dex/slice-slice_5-classes.dex",dex file "/data/data/example.com.demoapp/files/instant-run/dex/slice-slice_4-classes.dex",dex file "/data/data/example.com.demoapp/files/instant-run/dex/slice-slice_3-classes.dex",dex file "/data/data/example.com.demoapp/files/instant-run/dex/slice-slice_2-classes.dex",dex file "/data/data/example.com.demoapp/files/instant-run/dex/slice-slice_1-classes.dex",dex file "/data/data/example.com.demoapp/files/instant-run/dex/slice-slice_0-classes.dex",dex file "/data/data/example.com.demoapp/files/instant-run/dex/slice-realm-android-0.87.4_a528e85f9603c6e64968c150f61258a1621159d0-classes.dex",dex file "/data/data/example.com.demoapp/files/instant-run/dex/slice-jsr305-2.0.1_54f738210fc8c811d7251e6035f61735e3c90b00-classes.dex",dex file "/data/data/example.com.demoapp/files/instant-run/dex/slice-internal_impl-24.2.1_d63817604dbcd8615733073ed4cf6bd29db871e2-classes.dex",dex file "/data/data/example.com.demoapp/files/instant-run/dex/slice-internal_impl-24.2.1_d432bb06a79cf966d865aa5fa44c857409504f1f-classes.dex",dex file "/data/data/example.com.d

解决方法

您正在使用一个极其过时的Realm版本,Stetho-Realm 2.0.0不支持该版本.

您应该使用the 1.x branch of Stetho-Realm打开您的领域.

repositories {
    maven {
        url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
    }
}

dependencies {
    compile 'com.facebook.stetho:stetho:1.3.1'
    compile 'com.uphyca:stetho_realm:0.9.0'
}

猜你在找的Android相关文章