When i'm trying to compile some apks like framework-res.apk
, or FileExplorer.apk
i get the same error always
invalid resource directory name: /ApkTool/Decompiladas/MiuiFramework.apk/res values-mcc9998-mnc9999
invalid resource directory name: /ApkTool/Decompiladas/MiuiFramework.apk/res values-mcc9466-mnc9999
I know that I can fix this error rename the folder with only three numbers, but with an apk
, if I compile it renaming these folders the rom
don't boot.
Is there some way to build the apk
without rename these folders?
Thanks.
Those aren't valid mnc
or mcc
values. You can see on the Providing Alternative Resources page that mcc
ranges from 0 to 999, while mnc
ranges from 1 to 999.
Based on the naming of the framework. It seems you are dealing with a MIUI framework. That means its entirely possible that MIUI modified the AOSP qualifiers to allow such values. This means that MIUI would have their own modified aapt
from those changes which could handle those non-standard qualifiers.
I checked out ResourceTypes.h
to see what data type mcc
and mnc
are.
union {
struct {
// Mobile country code (from SIM). 0 means "any".
uint16_t mcc;
// Mobile network code (from SIM). 0 means "any".
uint16_t mnc;
};
uint32_t imsi;
};
As you can see they are both uint16_t
. So our max value is 65535
. So we could easily store 9998
and more without modifying the qualifiers themselves. This points the problem towards the aapt
validation.
If we look at AaptConfig.cpp
of aapt
we see the parseMcc
and parseMnc
methods which both have a variation of this check
if (c-val == 0 || c-val > 3) return false;
So basically any value greater than 3 digits is failed, thus giving you that error.
Now I don't know how MIUI utilizes those qualifiers but you have two options.
Build your own aapt
from source removing that check. You will need this commit, which adds support from other MIUI qualifier changes. To be safe. I would just build your aapt
from my platform_frameworks_base
repo. Due to the constant adapting nature of aapt
, applications are becoming harder and harder to recompile correctly. My fork of aapt
removes some unnecessary validations. (I do this because if you are decompiling an apk, it has already been compiled once, so its not apktool to ensure 100% compatibility like newer aapt
try to enforce).
Delete those directories res/values-mcc9998-mnc9999
and values-mcc9466-mnc9999
.