代码之家  ›  专栏  ›  技术社区  ›  Jaime Alcántara Arnela

API 19的资源字符串无效-Android

  •  2
  • Jaime Alcántara Arnela  · 技术社区  · 6 年前

    我收到一个应用程序崩溃的消息,我正在努力寻找原因。

    这似乎是因为资源中的一个错误字符而发生的。因此,阅读相关资料我发现,在api 19和之前,一些非utf8字符造成了麻烦。在坠机的那一刻,这根绳子正在显示: Loading document…

    “那” … “相当于”…“但我想知道是不是那引起了麻烦。可能是吗?这组字符对API 19及之前版本无效吗?

    编辑: 我添加PlayStore提供的跟踪(我所有的):

        "main" tid=1 Native 
    "main" prio=5 tid=1 Native
      | group="main" sCount=1 dsCount=0 obj=0x74b56000 self=0xb4df6500
                | sysTid=12348 nice=0 cgrp=default sched=0/0 handle=0xb6fbcb34
                | state=S schedstat=( 0 0 0 ) utm=806 stm=228 core=0 HZ=100
                | stack=0xbe419000-0xbe41b000 stackSize=8MB
      | held mutexes=
      #00  pc 0000000000017618  /system/lib/libc.so (syscall+28)
                #01  pc 00000000000f5ced  /system/lib/libart.so (_ZN3art17ConditionVariable4WaitEPNS_6ThreadE+80)
                #02  pc 0000000000267623  /system/lib/libart.so (_ZN3art3JNI12NewStringUTFEP7_JNIEnvPKc+610)
                #03  pc 000000000008952d  /system/lib/libandroid_runtime.so (???)
                #04  pc 000000000042c6bf  /data/dalvik-cache/arm/system@framework@boot.oat (Java_android_content_res_StringBlock_nativeGetString__JI+98)
        at android.content.res.StringBlock.nativeGetString (Native method)
        at android.content.res.StringBlock.get (StringBlock.java:82)
                - locked <0x066e19ac> (a android.content.res.StringBlock)
        at android.content.res.AssetManager.getResourceText (AssetManager.java:154)
                - locked <0x0fbb8675> (a android.content.res.AssetManager)
        at android.content.res.Resources.getText (Resources.java:308)
        at android.content.res.Resources.getString (Resources.java:400)
        at android.content.Context.getString (Context.java:409)
        at cat.enterprise.appname.modules.documents.view.DocumentsActivity.insertUnlockPasswordDialog (DocumentsActivity.java:628)
        at cat.enterprise.appname.modules.documents.view.DocumentsActivity.onDocumentClick (DocumentsActivity.java:544)
        at cat.enterprise.appname.adapter.DocumentItemAdapter$1.onClick (DocumentItemAdapter.java:344)
        at android.view.View.performClick (View.java:5204)
        at android.view.View$PerformClick.run (View.java:21153)
        at android.os.Handler.handleCallback (Handler.java:739)
        at android.os.Handler.dispatchMessage (Handler.java:95)
        at android.os.Looper.loop (Looper.java:148)
        at android.app.ActivityThread.main (ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke! (Native method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:742)
        at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:632)
                "FinalizerDaemon" tid=3 Waiting 
    "ReferenceQueueDaemon" tid=4 Waiting 
    "FinalizerWatchdogDaemon" tid=5 Waiting 
    "Binder_1" tid=7 Native 
    "Binder_2" tid=8 Native 
    "AsyncTask #1" tid=9 Waiting 
    "AsyncTask #2" tid=10 Waiting 
    "AsyncTask #3" tid=11 Waiting 
    "AsyncTask #4" tid=12 Waiting 
    "AsyncTask #5" tid=13 Waiting 
    "Okio Watchdog" tid=14 Waiting 
    "pool-2-thread-1" tid=15 Waiting 
    "RealmFinalizingDaemon" tid=16 Waiting 
    "Binder_3" tid=17 Native 
    "estiona.appname"
            "Signal Catcher" tid=2 Runnable
    

    谢谢

    1 回复  |  直到 6 年前
        1
  •  0
  •   Martin Zeitler    6 年前

    添加 values-v19/strings.xml 没有 U+2026 如果相似的字符,则会出现更多的情况。

    <?xml version="1.0" encoding="UTF-8"?>
    <resources xmlns:tools="http://schemas.android.com/tools">
        <string name="loading_text" tools:ignore="TypographyEllipsis">Loading document...</string>
    </resources>
    

    因为 JNI UTF-8 encoding bug with some characters ,可能有字符超出范围。