Kotlin GooglePlay商店中的应用程序崩溃,但在模拟器和物理设备上本地开发时不会崩溃

Kotlin GooglePlay商店中的应用程序崩溃,但在模拟器和物理设备上本地开发时不会崩溃,kotlin,crash,realm,Kotlin,Crash,Realm,在将我的应用升级到never版本并使用realm数据库后,当从GooglePlay下载时,它会崩溃,但当我在物理设备或许多模拟器上检查它时,它不会崩溃。怎么了?请帮忙。 在我的应用程序中,我使用StaticObject包装不同语言的一些领域配置,并使用inMemory real跟踪整个应用程序中选定的对象 问题: `java.lang.ExceptionInInitializerError: at pl.nanoid.atlasotoskopii.ui.Start.MainActivity

在将我的应用升级到never版本并使用realm数据库后,当从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)`
静态对象:

    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

}
内存领域方案:

    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)
11/12 07:49:17:在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
正在等待进程联机。。。
已连接到设备“Pixel_C_API_28[emulator-5554]”上的进程8060。
从应用程序捕获和显示logcat消息。可以在“调试器”设置页面的“Logcat输出”部分禁用此行为。
W/.atlasotoskopi:访问隐藏方法Landroid/graphics/drawable/drawable;->getOpticalInsets()Landroid/graphics/Insets;(浅灰色列表,链接)
访问隐藏字段Landroid/图形/插图;->左:I(浅灰色列表,链接)
访问隐藏字段Landroid/图形/插图;->右:I(浅灰色列表,链接)
访问隐藏字段Landroid/图形/插图;->顶部:I(浅灰色列表,链接)
访问隐藏字段Landroid/图形/插图;->底部:I(浅灰色列表,链接)
W/.atlasotoskopi:访问隐藏方法Landroid/view/view;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z(浅灰色列表,反射)
W/.atlasotoskopi:访问隐藏方法Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V(浅灰色列表,反射)
W/.atlasotoskopi:访问隐藏方法Landroid/graphics/FontFamily;->()V(浅灰色列表,反射)
W/.atlasotoskopi:访问隐藏方法Landroid/graphics/FontFamily;->addFontFromAssetManager(Landroid/content/res/AssetManager;Ljava/lang/String;IZIII[Landroid/graphics/fonts/FontVariationAxis;)Z(浅灰色列表,反射)
访问隐藏方法Landroid/graphics/FontFamily;->addFontFromBuffer(Ljava/nio/ByteBuffer;I[Landroid/graphics/fonts/FontVariationAxis;II)Z(浅灰色列表,反射)
访问隐藏方法Landroid/graphics/FontFamily;->freeze()Z(浅灰色列表,反射)
访问隐藏方法Landroid/graphics/FontFamily;->abortCreation()V(浅灰色列表,反射)
访问隐藏方法Landroid/graphics/Typeface;->createFromFamiliesWithDefault([Landroid/graphics/FontFamily;Ljava/lang/String;II)Landroid/graphics/Typeface;(浅灰色列表,反射)
W/.atlasotoskopi:访问隐藏方法Landroid/widget/TextView;->getTextDirectionHeuristic()Landroid/text/TextDirectionHeuristic;(浅灰色列表,链接)
D/OpenGLRenderer:Skia GL管道
D/HostConnection:HostConnection::get()已建立新主机连接0xe14ee260,tid 8111
D/主机连接:主机组合ext ANDROID\u EMU\u校验和\u HELPER\u v1 ANDROID\u EMU\u native\u sync\u v2 ANDROID\u EMU\u native\u sync\u v3 ANDROID\u EMU\u dma\u v1 ANDROID\u EMU\u YUV420\u 888\u到\u NV21 ANDROID\u EMU\u YUV\u缓存GL OES\u图像最大外部\u essl3 GL\u OES\u顶点数组\u对象GL\u KHR\u纹理压缩\u astc\u ldr\u ANDROID\u版本0
I/ConfigStore:android::hardware::ConfigStore::V1_0::ISurfaceFlingerConfigs::已检索到hasWideColorDisplay:0
I/ConfigStore:android::hardware::ConfigStore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay检索到:0
I/OpenGLRenderer:初始化EGL,版本1.4
D/OpenGLRenderer:交换行为1
W/OpenGLRenderer:未能选择保留EGL\u交换\u行为的配置,正在重试,但没有。。。
D/OpenGLRenderer:交换行为0
D/eglCodecCommon:setVertexArrayObject:将vao设置为0(0)0
D/EGL_仿真:eglCreateContext:0xe208b540:maj 3 min 0 rcv 3
D/EGL_仿真:eglMakeCurrent:0xe208b540:ver 3 0(tinfo 0xe41e0620)
D/HostConnection:createUnique:调用
HostConnection::get()已建立新主机连接0xe14f01f0,tid 8111
D/主机连接:主机组合ext ANDROID\u EMU\u校验和\u HELPER\u v1 ANDROID\u EMU\u native\u sync\u v2 ANDROID\u EMU\u native\u sync\u v3 ANDROID\u EMU\u dma\u v1 ANDROID\u EMU\u YUV420\u 888\u到\u NV21 ANDROID\u EMU\u YUV\u缓存GL OES\u图像最大外部\u essl3 GL\u OES\u顶点数组\u对象GL\u KHR\u纹理压缩\u astc\u ldr\u ANDROID\u版本0
E/eglCodecCommon:goldfishAddressSpaceHostMemoryLocator:ioctl\u ping设备类型=5失败,ret=-1
D/EGL_仿真:eglMakeCurrent:0xe208b540:ver 3 0(tinfo 0xe41e0620)
D/eglCodecCommon:setVertexArrayObject:将vao设置为0(0)1 2
W/ActivityThread:handleWindowVisibility:标记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_仿真:eglMakeCurrent:0xe208b540:ver 3 0(tinfo 0xe41e0620)
W/ActivityThread:handleWindowVisibility:标记android.os没有活动。BinderProxy@4db914d
D/EGL_仿真:eglMakeCurrent:0xe208b540:ver 3 0(tinfo 0xe41e0620)
W/ActivityThread:handleWindowVisibility:标记android.os没有活动。BinderProxy@aa9d30d
D/EGL_仿真:eglMakeCurrent:0xe208b540:ver 3 0(tinfo 0xe41e0620)

日志中是否有更多信息?此类问题通常表示您忘记添加库(或添加正确的版本)到您发布的应用程序。不,没有其他LogCat信息。我编辑了我的问题,以包括在emulator上运行的信息。为什么只有在商店上发布时才会崩溃?我很奇怪。您使用过任何google api密钥吗?不,我没有使用
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)