Package xyz has mismatched uid: 10044 on disk, 10045 in settings

最后都变了- 提交于 2019-12-21 01:29:37

问题


I found a simple guide to install an Android-x86 in a VM (guide).
Connection to Eclipse and all works fine, but installing my app on the VM fails with following errors:

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

I searched for the error at google and found a little Python script to fix the issue, but it doesn't work (script). After the execution of the script I got the same error.

I use Android-x86 2.2 generic, more details can be found here: Release 2.2

Is there any possibility to fix that problem?

EDIT:

I tested all 2.2 releases. Only generic and sparta work in general, but no one accepts my apk.
Tried with adb install <packagefile> too.

EDIT2:

I have tried the adviced tools from @Vlad. It works partially after signing the apk. Finally I used the apkTools and replaced the old files of apkEdit with the new from the apktool.
But the install with adb hangs up with the message waiting for device or nothing. If I believe eclipse DDMS the connection to the device will lost every time I try to install the apk.
Here is the failure when I try to install the normal apk: Failure [INSTALL_FAILED_INVALID_APK]


回答1:


Error Package xyz has mismatched uid: 10044 on disk, 10045 in settings caused by exist folder /data/data/xyz/.

In this message folder exists and have different owner (10044) from now installed (10045). It is caused by previous unclean install.

For example previous install failed with some errors and do not remove created folders.

Because in folder can be data from other app android can not allow use it. PackageManager try fix it in different ways but if can not do this - it get app different dir and show this message.

Better solution - install app and clean remove it. After that install it again.

Another solution - remove folder /data/data/xyz/ in some ways. May be you need root for this.

Code from PackageManager (comments may be very helpfull):

            // 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:


Your application appears to use native code. Do you use NDK? One way to check is to use "apktool dump badging "

see http://ibotpeaches.github.io/Apktool/

Look for something like native-code: 'armeabi' in the output




回答3:


The problem had to do with a program called "dexopt" which determines a fixed-size buffer called "LinearAlloc" of apps installed on a specific device. While the buffer size is 8 or 16 MB in size for newer Android versions like Ice Cream Sandwich and Jelly Bean, its only 5 MB in the older versions.

When you sign the apk, you probably execute proguard steps, which removes unreferenced code parts(classes, methods, fields etc.) So you pass that error related with the buffer size.

But proguard may not be a solution every time, you still have the possibility to exceed the buffer size limit.

Facebook has a solution for this: "Breaking our app into multiple dex files". See: https://www.facebook.com/notes/facebook-engineering/under-the-hood-dalvik-patch-for-facebook-for-android/10151345597798920



来源:https://stackoverflow.com/questions/6431759/package-xyz-has-mismatched-uid-10044-on-disk-10045-in-settings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!