我找到了一个在VM中安装Android-x86的简单指南(guide) 连接到Eclipse并且一切正常,但在VM上安装我的应用程序失败并出现以下错误:
06-21 22:40:26.390: INFO/PackageManager(2439): /data/app/xyz.apk changed; unpacking
06-21 22:40:26.390: ERROR/PackageManager(2439): Package xyz has mismatched uid: 10044 on disk, 10045 in settings
06-21 22:40:26.390: WARN/PackageManager(2439): Native ABI mismatch from package file
06-21 22:40:26.390: WARN/PackageManager(2439): Package couldn't be installed in /data/app/xyz-1.apk
我在google上搜索了错误并找到了一个Python脚本来解决这个问题,但它不起作用(script)。在执行脚本后,我得到了同样的错误。
我使用Android-x86 2.2泛型,更多细节可以在这里找到:Release 2.2
有没有可能解决这个问题?
编辑:
我测试了所有2.2版本。一般只有泛型和sparta工作,但没有人接受我的apk
也试过adb install <packagefile>
。
EDIT2:
我尝试过来自@Vlad的推荐工具。它在签署apk后部分工作。最后我使用apkTools并用apktool中的new替换了apkEdit的旧文件
但是使用adb的安装会挂起消息等待设备或什么都没有。如果我相信eclipse DDMS,每次我尝试安装apk时,与设备的连接都会丢失
当我尝试安装普通 apk:Failure [INSTALL_FAILED_INVALID_APK]
答案 0 :(得分:1)
您的应用似乎使用本机代码。你使用NDK吗? 检查的一种方法是使用 “apktool dump badging”
请参阅http://ibotpeaches.github.io/Apktool/
寻找类似的东西 原生代码:'armeabi' 在输出中
答案 1 :(得分:1)
现有文件夹Package xyz has mismatched uid: 10044 on disk, 10045 in settings
导致错误/data/data/xyz/
。
在此消息文件夹中存在并且具有从现在开始安装的不同所有者(10044)(10045)。这是由以前的不洁安装造成的。
例如,之前的安装失败并出现一些错误,并且不删除已创建的文件夹。
因为在文件夹中可以将来自其他app的数据安卓不能允许使用它。PackageManager
尝试以不同的方式修复它,但如果不能这样做 - 它会获得不同的dir并显示此消息。
更好的解决方案 - 安装应用并清除它。之后再安装它。
另一种解决方案 - 以某种方式删除文件夹/data/data/xyz/
。可能你需要根源。
来自PackageManager
的代码(评论可能非常有帮助):
// This is a normal package, need to make its data directory.
dataPath = getDataPathForPackage(pkg.packageName, 0);
boolean uidError = false;
if (dataPath.exists()) {
// XXX should really do this check for each user.
mOutPermissions[1] = 0;
FileUtils.getPermissions(dataPath.getPath(), mOutPermissions);
// If we have mismatched owners for the data path, we have a problem.
if (mOutPermissions[1] != pkg.applicationInfo.uid) {
boolean recovered = false;
if (mOutPermissions[1] == 0) {
// The directory somehow became owned by root. Wow.
// This is probably because the system was stopped while
// installd was in the middle of messing with its libs
// directory. Ask installd to fix that.
int ret = mInstaller.fixUid(pkgName, pkg.applicationInfo.uid,
pkg.applicationInfo.uid);
if (ret >= 0) {
recovered = true;
String msg = "Package " + pkg.packageName
+ " unexpectedly changed to uid 0; recovered to " +
+ pkg.applicationInfo.uid;
reportSettingsProblem(Log.WARN, msg);
}
}
if (!recovered && ((parseFlags&PackageParser.PARSE_IS_SYSTEM) != 0
|| (scanMode&SCAN_BOOTING) != 0)) {
// If this is a system app, we can at least delete its
// current data so the application will still work.
int ret = mInstaller.remove(pkgName, 0);
if (ret >= 0) {
// TODO: Kill the processes first
// Remove the data directories for all users
sUserManager.removePackageForAllUsers(pkgName);
// Old data gone!
String prefix = (parseFlags&PackageParser.PARSE_IS_SYSTEM) != 0
? "System package " : "Third party package ";
String msg = prefix + pkg.packageName
+ " has changed from uid: "
+ mOutPermissions[1] + " to "
+ pkg.applicationInfo.uid + "; old data erased";
reportSettingsProblem(Log.WARN, msg);
recovered = true;
// And now re-install the app.
ret = mInstaller.install(pkgName, pkg.applicationInfo.uid,
pkg.applicationInfo.uid);
if (ret == -1) {
// Ack should not happen!
msg = prefix + pkg.packageName
+ " could not have data directory re-created after delete.";
reportSettingsProblem(Log.WARN, msg);
mLastScanError = PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
return null;
}
// Create data directories for all users
sUserManager.installPackageForAllUsers(pkgName,
pkg.applicationInfo.uid);
}
if (!recovered) {
mHasSystemUidErrors = true;
}
} else if (!recovered) {
// If we allow this install to proceed, we will be broken.
// Abort, abort!
mLastScanError = PackageManager.INSTALL_FAILED_UID_CHANGED;
return null;
}
if (!recovered) {
pkg.applicationInfo.dataDir = "/mismatched_uid/settings_"
+ pkg.applicationInfo.uid + "/fs_"
+ mOutPermissions[1];
pkg.applicationInfo.nativeLibraryDir = pkg.applicationInfo.dataDir;
String msg = "Package " + pkg.packageName
+ " has mismatched uid: "
+ mOutPermissions[1] + " on disk, "
+ pkg.applicationInfo.uid + " in settings";
// writer
synchronized (mPackages) {
mSettings.mReadMessages.append(msg);
mSettings.mReadMessages.append('\n');
uidError = true;
if (!pkgSetting.uidError) {
reportSettingsProblem(Log.ERROR, msg);
}
}
}
}
pkg.applicationInfo.dataDir = dataPath.getPath();
答案 2 :(得分:0)
问题与名为&#34; dexopt&#34;的程序有关。这决定了 一个固定大小的缓冲区,名为&#34; LinearAlloc&#34;安装的应用程序 具体设备。虽然较新的缓冲区大小为8或16 MB Android版本如Ice Cream Sandwich和Jelly Bean,仅有5 MB 在旧版本中。
当你签署apk时,你可能会执行proguard步骤,这会删除未引用的代码部分(类,方法,字段等)。所以你传递了与缓冲区大小相关的错误。
但是proguard每次都可能不是解决方案,你仍有可能超过缓冲区大小限制。
Facebook有一个解决方案:&#34;将我们的应用分成多个dex文件&#34;。请参阅:https://www.facebook.com/notes/facebook-engineering/under-the-hood-dalvik-patch-for-facebook-for-android/10151345597798920