我正在使用领域。我安装了 Stetho-Realm 来查看领域数据。
这就是我所做的。
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'
}
}
}
应用程序分级
- 听诊器:1.5.0
- stetho_realm:2.1.0
- 多索引:1.0.3
- multiDexEnabled 真
这是gradle代码。
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'
}
我的应用类
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);
}
}
但应用程序因此错误而崩溃:在 android studio 上运行后,应用程序安装正常。应用程序出现在设备上后,我在“chrome://inspect/#devices:”中单击了“检查”。此时,应用程序崩溃并显示错误。如何通过 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]]