将我的应用程序升级到永不版本并使用领域数据库后,从GooglePlay下载该应用程序时它会崩溃,但是当我在物理设备或许多模拟器上对其进行检查时,它绝不会崩溃。怎么了?请帮助。 在我的应用程序中,我使用StaticObject来包装用于不同语言的一些领域配置,并使用inmemory real来跟踪整个应用程序中选定对象的情况。
问题:
`java.lang.ExceptionInInitializerError:
at pl.nanoid.atlasotoskopii.ui.Start.Mainactivity.onCreate (20)
at android.app.activity.performCreate (activity.java:7458)
at android.app.activity.performCreate (activity.java:7448)
at android.app.Instrumentation.callactivityOnCreate (Instrumentation.java:1286)
at android.app.activityThread.performLaunchactivity (activityThread.java:3409)
at android.app.activityThread.handleLaunchactivity (activityThread.java:3614)
at android.app.servertransaction.LaunchactivityItem.execute (LaunchactivityItem.java:86)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
at android.app.activityThread$H.handleMessage (activityThread.java:2199)
at android.os.Handler.dispatchMessage (Handler.java:112)
at android.os.Looper.loop (Looper.java:216)
at android.app.activityThread.main (activityThread.java:7625)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:987)
Caused by: java.lang.IllegalArgumentException:
at c.a.q$a.a (3)
at c.a.q$a.a (Unknown Source:5)
at pl.nanoid.atlasotoskopii.StaticObject.<clinit> (3)`
Mainactivity:
class Mainactivity : AppCompatactivity() {
lateinit var inmemRealm: Realm
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
try {
this.supportactionBar?.hide()
} finally {
}
setContentView(R.layout.activity_main)
val navView: BottomNavigationView = findViewById(R.id.nav_view)
val navController = findNavController(R.id.nav_host_fragment)
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
val appBarConfiguration = AppBarConfiguration(
setOf(
R.id.navigation_list,R.id.navigation_info,R.id.navigation_pictures
)
)
setupactionBarWithNavController(navController,appBarConfiguration)
navView.setupWithNavController(navController)
// Configure Realm database and create in memory Realm for selecting items
inmemRealm = Realm.getInstance(StaticObject.inmemoryRealm)
inmemRealm.executeTransaction {
val inmem = InmemRealm()
inmem.id = 1
inmemRealm.insert(inmem)
}
copyDatabaseFromBundle()
}
// COPY DATABASE from bundle to the working directory
private fun copyDatabaseFromBundle() {
}
}
StaticObject:
object StaticObject {
// value for number of items for adapters:
const val numberOfItemsInAdapters: Int = 24
val inmemoryRealm: RealmConfiguration
val enRealmConfig: RealmConfiguration
val plRealmConfig: RealmConfiguration
val ruRealmConfig: RealmConfiguration
init {
enRealmConfig = configureENRealm()
plRealmConfig = configurePLRealm()
ruRealmConfig = configureRURealm()
inmemoryRealm = configureInmemoryRealm()
}
private fun configureENRealm () : RealmConfiguration {
return RealmConfiguration.Builder()
.assetfile("tableen.realm")
.schemaVersion(1)
.modules(TableEnmodule())
.name("rurealm.realm")
.readOnly()
.build()
}
private fun configurePLRealm () : RealmConfiguration {
return RealmConfiguration.Builder()
.assetfile("tablepl.realm")
.schemaVersion(1)
.modules(TablePLModule())
.name("plrealm.realm")
.readOnly()
.build()
}
private fun configureRURealm () : RealmConfiguration {
return RealmConfiguration.Builder()
.assetfile("tableru.realm")
.schemaVersion(1)
.modules(TableRUModule())
.name("enrealm.realm")
.readOnly()
.build()
}
private fun configureInmemoryRealm () : RealmConfiguration {
return RealmConfiguration.Builder()
.inmemory()
.name("inmemoryRealm")
.build()
}
@RealmModule(classes = arrayOf(tableen::class))
private class TableEnmodule
@RealmModule(classes = arrayOf(tablepl::class))
private class TablePLModule
@RealmModule(classes = arrayOf(tableru::class))
private class TableRUModule
}
Inmemory Realm方案:
import io.realm.RealmObject
open class InmemRealm: RealmObject() {
var id: Int? = null
}
在模拟器上运行:
11/12 07:49:17: launching 'app' on Pixel C API 28.
$ adb shell am start -n "pl.nanoid.atlasotoskopii/pl.nanoid.atlasotoskopii.ui.Start.Startactivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Waiting for process to come online...
Connected to process 8060 on device 'Pixel_C_API_28 [emulator-5554]'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
W/.atlasotoskopi: accessing hidden method Landroid/graphics/drawable/Drawable;->getOpticalInsets()Landroid/graphics/Insets; (light greylist,linking)
accessing hidden field Landroid/graphics/Insets;->left:I (light greylist,linking)
accessing hidden field Landroid/graphics/Insets;->right:I (light greylist,linking)
accessing hidden field Landroid/graphics/Insets;->top:I (light greylist,linking)
accessing hidden field Landroid/graphics/Insets;->bottom:I (light greylist,linking)
W/.atlasotoskopi: accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist,reflection)
W/.atlasotoskopi: accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist,reflection)
W/.atlasotoskopi: accessing hidden method Landroid/graphics/FontFamily;-><init>()V (light greylist,reflection)
W/.atlasotoskopi: accessing hidden method Landroid/graphics/FontFamily;->addFontFromAssetManager(Landroid/content/res/AssetManager;Ljava/lang/String;IZIII[Landroid/graphics/fonts/FontVariationAxis;)Z (light greylist,reflection)
accessing hidden method Landroid/graphics/FontFamily;->addFontFromBuffer(Ljava/nio/ByteBuffer;I[Landroid/graphics/fonts/FontVariationAxis;II)Z (light greylist,reflection)
accessing hidden method Landroid/graphics/FontFamily;->freeze()Z (light greylist,reflection)
accessing hidden method Landroid/graphics/FontFamily;->abortCreation()V (light greylist,reflection)
accessing hidden method Landroid/graphics/Typeface;->createFromFamiliesWithDefault([Landroid/graphics/FontFamily;Ljava/lang/String;II)Landroid/graphics/Typeface; (light greylist,reflection)
W/.atlasotoskopi: accessing hidden method Landroid/widget/TextView;->getTextDirectionHeuristic()Landroid/text/TextDirectionHeuristic; (light greylist,linking)
D/OpenGLRenderer: Skia GL Pipeline
D/HostConnection: HostConnection::get() New Host Connection established 0xe14ee260,tid 8111
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_0
I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceflingerConfigs::hasWideColorDisplay retrieved: 0
I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceflingerConfigs::hasHDRDisplay retrieved: 0
I/OpenGLRenderer: Initialized EGL,version 1.4
D/OpenGLRenderer: Swap behavior 1
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED,retrying without...
D/OpenGLRenderer: Swap behavior 0
D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0
D/EGL_emulation: eglCreateContext: 0xe208b540: maj 3 min 0 rcv 3
D/EGL_emulation: eglMakeCurrent: 0xe208b540: ver 3 0 (tinfo 0xe41e0620)
D/HostConnection: createUnique: call
HostConnection::get() New Host Connection established 0xe14f01f0,tid 8111
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_0
E/eglCodecCommon: GoldfishAddressspaceHostMemoryAllocator: ioctl_ping failed for device_type=5,ret=-1
D/EGL_emulation: eglMakeCurrent: 0xe208b540: ver 3 0 (tinfo 0xe41e0620)
D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 1 2
W/activityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@9195193
I/System.out: @drawable/photo1min
I/System.out: @drawable/photo2min
I/System.out: @drawable/photo3min
I/System.out: @drawable/photo4min
I/System.out: @drawable/photo5min
I/System.out: @drawable/photo6min
D/EGL_emulation: eglMakeCurrent: 0xe208b540: ver 3 0 (tinfo 0xe41e0620)
W/activityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@4db914d
D/EGL_emulation: eglMakeCurrent: 0xe208b540: ver 3 0 (tinfo 0xe41e0620)
W/activityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@aa9d30d
D/EGL_emulation: eglMakeCurrent: 0xe208b540: ver 3 0 (tinfo 0xe41e0620)