美文网首页
最近问题总结

最近问题总结

作者: 学无止境的cy | 来源:发表于2022-11-10 16:13 被阅读0次

    1.okhttp3请求头的问题

    在最近收集的日志发现这个异常:Java.lang.IllegalArgumentException:Unexpected char 0x4e2d at 0 in wifi value:
    可以定位到是请求的头部key为wifi的这个字段出了问题,而且基本可以判断成编码问题。再去看下okhttp3这个包里的header类发现了这个方法

      private void checkNameAndValue(String name, String value) {
          if (name == null) throw new NullPointerException("name == null");
          if (name.isEmpty()) throw new IllegalArgumentException("name is empty");
          for (int i = 0, length = name.length(); i < length; i++) {
            char c = name.charAt(i);
            if (c <= '\u0020' || c >= '\u007f') {
              throw new IllegalArgumentException(Util.format(
                  "Unexpected char %#04x at %d in header name: %s", (int) c, i, name));
            }
          }
          if (value == null) throw new NullPointerException("value for name " + name + " == null");
          for (int i = 0, length = value.length(); i < length; i++) {
            char c = value.charAt(i);
            if ((c <= '\u001f' && c != '\t') || c >= '\u007f') {
              throw new IllegalArgumentException(Util.format(
                  "Unexpected char %#04x at %d in %s value: %s", (int) c, i, name, value));
            }
          }
    

    可以看到在请求之前会检查一遍header中的name和value,其中name只支持大于'\u001f'或者小于'\u007f'的字符。

    解决方法:和后台约定好统一的转码方式进行转码就好了。

    2.ArrayList和LinkedList在不同手机的顺序问题

    由于我们app和后台接口都是加密传输的,解密的key是和发送的内容是相关的。有天后台反馈有的用户的某些接口无法解密。由于我们对塞入的数据顺序是有严格要求的,结合我几年碰到一个问题,在某些手机上Arraylist确实和常规手机上的输出顺序是不同的,改完linkedlist就好了,具体原因后面有空会继续研究并更新

    3. A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable

    com.android.ide.common.signing.KeytoolException: Failed to read key key0 from store
    网上看了一大堆什么删除debug文件都不行,同一套代码更换了android studio版本就不行了,简单粗暴的办法直接升级项目当前的jdk版本 只要11及以上就行了,在setting->gradle->gradle JDK指定JDK版本就好了

    相关文章

      网友评论

          本文标题:最近问题总结

          本文链接:https://www.haomeiwen.com/subject/nsnklltx.html