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

后端 未结 3 1992
情深已故
情深已故 2021-02-09 00:45

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:

相关标签:
3条回答
  • 2021-02-09 01:38

    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

    0 讨论(0)
  • 2021-02-09 01:46

    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

    0 讨论(0)
  • 2021-02-09 01:51

    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(); 
    
    0 讨论(0)
提交回复
热议问题