尝试从strings.xml获取String数组时出错

时间:2018-05-22 08:39:57

标签: java android arrays android-ndk

我在strings.xml文件中有2个和1个巨大的字符串数组,它包含在标记中。

当我尝试使用 getResources().getStringArray(R.array.some_name) 获取数据时,前两个阵列工作正常,但最后一个数据量很大(每个项目的长内容)会在某些手机上引发错误(例如在我的Nexus 6p Android 8.1(官方)上)。我试图最小化数组的数据,但仍然会出错。

这是错误日志:

05-22 11:36:09.541 15746-15746/kvazios.mylifestory A/zygote64: java_vm_ext.cc:534] JNI DETECTED ERROR IN APPLICATION: chars == null && char_count > 0
    java_vm_ext.cc:534]     in call to NewString
    java_vm_ext.cc:534]     from java.lang.String[] android.content.res.AssetManager.getArrayStringResource(int)
    java_vm_ext.cc:534] "main" prio=5 tid=1 Runnable
    java_vm_ext.cc:534]   | group="main" sCount=0 dsCount=0 flags=0 obj=0x72bf25f0 self=0x7b51abea00
    java_vm_ext.cc:534]   | sysTid=15746 nice=-4 cgrp=default sched=0/0 handle=0x7bd657d9a8
    java_vm_ext.cc:534]   | state=R schedstat=( 3054541310 145051602 2178 ) utm=278 stm=26 core=4 HZ=100
    java_vm_ext.cc:534]   | stack=0x7fdb54b000-0x7fdb54d000 stackSize=8MB
    java_vm_ext.cc:534]   | held mutexes= "mutator lock"(shared held)
    java_vm_ext.cc:534]   native: #00 pc 00000000003ccb5c  /system/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*)+208)
    java_vm_ext.cc:534]   native: #01 pc 000000000049cdf4  /system/lib64/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+348)
    java_vm_ext.cc:534]   native: #02 pc 00000000002fe388  /system/lib64/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1048)
    java_vm_ext.cc:534]   native: #03 pc 00000000002fe878  /system/lib64/libart.so (art::JavaVMExt::JniAbortF(char const*, char const*, ...)+180)
    java_vm_ext.cc:534]   native: #04 pc 000000000037ccdc  /system/lib64/libart.so (art::JNI::NewString(_JNIEnv*, unsigned short const*, int)+992)
    java_vm_ext.cc:534]   native: #05 pc 00000000001017c4  /system/lib64/libart.so (art::CheckJNI::NewString(_JNIEnv*, unsigned short const*, int)+664)
    java_vm_ext.cc:534]   native: #06 pc 000000000011a088  /system/lib64/libandroid_runtime.so (???)
    java_vm_ext.cc:534]   native: #07 pc 00000000004834c4  /system/framework/arm64/boot-framework.oat (Java_android_content_res_AssetManager_getArrayStringResource__I+132)
    java_vm_ext.cc:534]   at android.content.res.AssetManager.getArrayStringResource(Native method)
    java_vm_ext.cc:534]   at android.content.res.AssetManager.getResourceStringArray(AssetManager.java:208)
    java_vm_ext.cc:534]   at android.content.res.Resources.getStringArray(Resources.java:573)
    java_vm_ext.cc:534]   at kvazios.mylifestory.DescriptionActivity.loadOffline(DescriptionActivity.java:888)
    java_vm_ext.cc:534]   at kvazios.mylifestory.DescriptionActivity.onCreate(DescriptionActivity.java:108)
    java_vm_ext.cc:534]   at android.app.Activity.performCreate(Activity.java:6999)
    java_vm_ext.cc:534]   at android.app.Activity.performCreate(Activity.java:6990)
    java_vm_ext.cc:534]   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
    java_vm_ext.cc:534]   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
    java_vm_ext.cc:534]   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
    java_vm_ext.cc:534]   at android.app.ActivityThread.-wrap11(ActivityThread.java:-1)
    java_vm_ext.cc:534]   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
    java_vm_ext.cc:534]   at android.os.Handler.dispatchMessage(Handler.java:106)
    java_vm_ext.cc:534]   at android.os.Looper.loop(Looper.java:164)
    java_vm_ext.cc:534]   at android.app.ActivityThread.main(ActivityThread.java:6494)
    java_vm_ext.cc:534]   at java.lang.reflect.Method.invoke(Native method)
    java_vm_ext.cc:534]   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    java_vm_ext.cc:534]   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
    java_vm_ext.cc:534] 

0 个答案:

没有答案