美文网首页
关于android属性persistent的问题

关于android属性persistent的问题

作者: 还是做个码农 | 来源:发表于2022-09-29 00:05 被阅读0次

    问题描述

    在一次系统应用的运行调试中,出现下面的报错:

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.test/com.android.test.TestMainActivity}: java.lang.ClassCastException: android.support.v7.widget.ContentFrameLayout cannot be cast to android.support.v7.widget.ContentFrameLayout

    明明时同个类型确却报出类型转换异常,考虑当前系统应用的特殊性,对比其他应用从未发现此现象,发现此问题是声明了 persistent属性持久化带来的影响。

    解决方案

    persistent应用不建议用于安装,如果已经安装了应用,则需要卸载后再安装,或者push到系统app目录下。
    由于persistent应用在启动时 AM S会对系统system应用的 Manifest 进行缓存,因此在push应用后,Manifest 依旧为原来的配置,需要对此目录中对应的应用缓存删除,Android 9的目录为:

    /data/system/package_cache/1

    或者删除原有 /system/priv-app/ 下的应用,再install apk安装,每次安装apk时会生成新的安装应用的缓存。
    如果不想删除缓存,也可以修改版本号编译新apk放入系统目录下。

    相关文章

      网友评论

          本文标题:关于android属性persistent的问题

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