本文介绍了Android 4.4的奇巧 - 共享preferences返回INSTALL_FAILED_SHARED_USER_INCOMPATIBLE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经工作了一段时间,现在的目标至少4.0 ICS的项目。最近,我得到了一个新的游戏版Moto G的是,正在运行的所有更新之后,运行的是4.4(KK)。所以我决定我想尝试并在其上部署程序,以及我有另外两个测试设备。

I've been working on a project for some time now that's targeting a minimum of 4.0 ICS. Recently, I got a new Play Edition Moto G that, after running all updates, is running 4.4 (KK). So I decided I wanted to try and deploy the program on it as well as the other two test devices that I have.

一切都进行得很好,直到我的程序到了一个地步,它试图通过preferenceManager.getDefaultShared preferences(上下文)来访问共享preference。调试并通过每帧运行后,我能弄清楚,值实际上写入到preferences文件(或者至少看起来是因为在共享preference对象地图容器包含的值我放在那里previously)。然而,当我试图用各自的密钥来读取任何值,我得到一个INSTALL_FAILED_SHARED_USER_INCOMPATIBLE值来代替,而这是造​​成我的程序直接崩溃(不是,但它导致需要从preferences适当的输出失败诉讼职能)。这只是发生在4.4到我的知识。

Everything was going fine until my program got to a point where it was trying to access SharedPreference via PreferenceManager.getDefaultSharedPreferences(Context). After debugging and running through each frame, I was able to figure out that values are in fact written to the preferences file (or at least appear to be since the Map container in the SharedPreference object contains the values I put there previously). However when I attempt to read any of the values with their respective keys, I'm getting a INSTALL_FAILED_SHARED_USER_INCOMPATIBLE value instead and that's causing my program to crash (not directly but it's causing proceeding functions that require the proper output from Preferences to fail). This only happens on 4.4 to my knowledge.

我已经冲刷净等对这个答案,我似乎无法找到任何解决我的问题。我的清单不声明或sharedUserId所以sharedUserLabel我不认为这会导致该问题。我已经卸载了好几次重新安装包无济于事。我是用于共享preference XML文件写入到程序的本地目录中的IM pression我理解为授予程序本身至少读/写访问(除非这是4.4是什么改变了下)。它似乎没有被存储在一个外部源那个位置由于摩托G具有在它没有SD卡

I've scoured the net and SO for answers on this and I can't seem to find anything that solves my problem. My manifest doesn't declare a sharedUserId or sharedUserLabel so I don't think that would be causing the issue. I've uninstalled and re-installed the package quite a few times to no avail. I was under the impression that the XML file used for SharedPreference was written to the program's local directory which I understood to grant at least read/write access by the program itself (unless this is what changed in 4.4). And it doesn't appear to be storing that location on a external source since the Moto G has no SD Card in it.

有没有人有任何想法如何解决此问题?目前的情况是,我的计划是不能够被部署在4.4的设备和我真的很喜欢,并非是这种情况。

Does anyone have any idea how to work around this? As it stands now, my program isn't able to be deployed on 4.4 devices and I would really like for that not to be the case.

推荐答案

因此​​,一些侦探后,我终于想通了,我的问题。这是多语无伦次SO职位的高潮,只是不值钱附近的谷歌搜索一样多。

So after some sleuthing, I eventually figured out my problem. It was a culmination of multiple incoherent SO posts and just as many near worthless Google searches.

我的一些preferences需要他们写入到文件之前,显然自4.2 Android已经使用OpenSSL的为新的安全提供比传统加密之一进行加密。所以经过花了几天研究,我可以通过这两个强制使用加密的SP,更明确规定了加密和变换算法/模式/填充,以帮助不仅使块大小一致,但这样它更解决我的问题明确这是怎么回事,而不是让API确定哪些可能是最好的。在这种情况下,即使执行加密后,它仍然打破从而进一步挖掘A / M / P。

Some of my preferences need to be encrypted before they're written to the file and apparently since 4.2 Android has used OpenSSL as the new Security Provider over the traditional Crypto one. So after spending a few days researching, I was able to solve my problem by both enforcing the use of the Crypto SP and more clearly specifying the encryption and transformation algorithm/mode/padding to help not only make block size consistent but so that it's more clear what's going on instead of letting the API determine what might be the best. In this case, even after enforcing Crypto, it was still broken hence the further digging into A/M/P.

所以,我最初的问题掩盖了实际的异常,这是超级好玩的明白这一点。

So my initial problem was masking the actual exception and it was super fun to figure that out.

这篇关于Android 4.4的奇巧 - 共享preferences返回INSTALL_FAILED_SHARED_USER_INCOMPATIBLE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 17:34