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

3

8

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]

Fenwick answered 21/6, 2011 at 20:45 Comment(1)
If you don't have problem after signing your apk, its probably proguard removes unreferenced classes/methods and your dex file decreases. Check my answer. Your problem is a common bug.Secularism
H
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(); 
Hildegardhildegarde answered 14/5, 2016 at 21:34 Comment(0)
B
1

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

Bettiebettina answered 23/6, 2011 at 0:54 Comment(3)
Yes I use native code and yes in my apk-file is the generated *.so. But how to use the apktool dump badging, there is no option.Fenwick
So looks like the target CPU of your native code is different from CPU used on your x86 system. Make sure to use NDK from android-x86.org See more details at: groups.google.com/group/android-x86/browse_thread/thread/…Bettiebettina
It works partially after signing the apk. Finally I used the apkTools from forum.xda-developers.com/showthread.php?t=882742 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. EDIT: Here is the failure when I try to install the "normal" apk: Failure [INSTALL_FAILED_INVALID_APK]Fenwick
H
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(); 
Hildegardhildegarde answered 14/5, 2016 at 21:34 Comment(0)
S
0

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

Secularism answered 31/3, 2014 at 12:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.