问题
I am using Realm. I installed Stetho-Realm to view realm data.
This is what i have done.
buildscript {
...
repositories {
google()
jcenter()
...
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
...
classpath "io.realm:realm-gradle-plugin:5.1.0"
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
}
maven {
url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
}
}
}
App gradle
- stetho:1.5.0
- stetho_realm:2.1.0
- multidex:1.0.3
- multiDexEnabled true
This is gradle code.
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 27
defaultConfig {
...
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
...
}
dependencies {
...
// Stetho
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.uphyca:stetho_realm:2.1.0'
}
My app class
public class MyApp extends Application{
@Override
public void onCreate() {
super.onCreate();
Realm.init(this);
RealmConfiguration config = new RealmConfiguration.Builder().build();
Realm.setDefaultConfiguration(config);
// Stetho
Stetho.initialize(
Stetho.newInitializerBuilder(this)
.enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(RealmInspectorModulesProvider.builder(this).build())
.build());
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
But App is crashing with this error : After Run on android studio, App was installed normally. I clicked "Inspect" in "chrome://inspect/#devices:" after the app appeared on the device. At this point, the app was crashed and shows the error. How can I see the realm db through Stetho?:
E/AndroidRuntime: FATAL EXCEPTION: StethoWorker-main-13
...
java.lang.NoClassDefFoundError: Failed resolution of: Lio/realm/internal/LinkView;
at java.lang.reflect.Executable.getParameterTypesInternal(Native Method)
at java.lang.reflect.Method.getParameterTypes(Method.java:179)
at java.lang.Class.getDeclaredMethods(Class.java:1881)
at com.facebook.stetho.inspector.MethodDispatcher.buildDispatchTable(MethodDispatcher.java:115)
at com.facebook.stetho.inspector.MethodDispatcher.findMethodDispatcher(MethodDispatcher.java:53)
at com.facebook.stetho.inspector.MethodDispatcher.dispatch(MethodDispatcher.java:60)
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.LinkView" on path: DexPathList[[zip file "/data/app/io.MyApp.app-xknjnMn3NM61rqAc4Zy3uA==/base.apk"],nativeLibraryDirectories=[/data/app/io.MyApp.app-xknjnMn3NM61rqAc4Zy3uA==/lib/arm64, /data/app/io.MyApp.app-xknjnMn3NM61rqAc4Zy3uA==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
回答1:
Stetho-Realm is unmaintained and doesn't support Realm version above 3.7.1
However there is a community fork: https://github.com/wickedev/stetho-realm
repositories {
maven { url 'https://github.com/WickeDev/stetho-realm/raw/master/maven-repo' }
}
dependencies {
implementation 'com.uphyca:stetho_realm:2.3.0'
}
val realmInspector = RealmInspectorModulesProvider.builder(this)
.withDeleteIfMigrationNeeded(true)
.build()
Stetho.initialize(Stetho.newInitializerBuilder(this)
.enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(realmInspector)
.build())
回答2:
I prefer using Realm Studio over stetho which is available for both Windows and Mac. You can simple pull the realm db file using adb command
adb pull /[path to local storage]/android/data//files/[realm file] [path of folder on your pc]
来源:https://stackoverflow.com/questions/51379564/noclassdeffounderror-failed-resolution-of-lio-realm-internal-linkview