[Android Themes] Masake:
I have been interested in theming an MTK 6592 mediatek phone (Infinix Hot Note x551) I have owned for quite a while. Its currently running Stock Android 5.1 Lollipop.

I reached a point where I needed to decompile and recompile the mediatek-res.apk framework resource app.

I was using apktool version 2.1.1 and later on 2.2.0-a4270d-SNAPSHOT

I wanted to get rid of this notification item, every time you opened the Dialer, Contacts or Mms application. I found it annoying - asking every time to choose a default simcard, when I clearly wanted and is able to choose a line on calls, or outgoing SMSs.

After a few weeks of on-of/trial and error research, I realized that these could be accomplished by editing the mediatek-res.apk located in /system/framework/mediatek-res.

It decompiled ok, but could not compile after editing(again, trial-error).

These were the compilation errors I was getting: A tonne of errors concerning all the resources and their Id's:

W: /home/*****/Desktop/mtk/mediatek-res/res/layout/account_five.xml:6: error: Error: No resource found that matches the given name (at 'id' with value '@id/account_five_img').

I read up on this error and one post here on XDA (didnt save the link, sorry) and also over at github, said to edit the

apktool.yml

file and include the framework ID for the mediatek-res.apk (already installed via 'apktool if mediatek-res.apk'). Its framework ID was 8. So I added it.

usesFramework:
ids:
- 1

to

usesFramework:
ids:
- 1
- 8

On compilation, a ton of these new errors came up:

W: /home/*****/Desktop/mtk/mediatek-res/res/values/styles.xml:3: error: Resource entry style/ImageSwitch is already defined in package com.mediatek.

Looked around furrther for quite sometime couldnt get a solution to this new errors. I continued on my trial and error ways and discovered that If edited the apktoo.yml file

sharedLibrary: false

to

sharedLibrary: true

and removed the mediatek-res framework ID from apktool.yml file, the errors were reduced to TWO!!

W: /home/*****/Desktop/mtk/mediatek-res/res/values/public.xml:914: error: Public symbol ^attr-private/factor declared here is not defined.

W: /home/*****/Desktop/mtk/mediatek-res/res/values/public.xml:915: error: Public symbol ^attr-private/scale declared here is not defined.

On investigating the error, I found out that indeed the two resources( ^attr-private/scale & ^attr-private/factor) were not defined in Ids.xml located in /res/values. I added the two to the bottom of the file,

<item type="^attr-private" name="factor">false</item>
<item type="^attr-private" name="scale">false</item>

Also I renamed the file

^attr-privates.xml

to ^attr-private.xml

On compilation, NO ERRORS!! and the app but pushed to system the phone ends up in endless bootloop.

I finally resolved the bootloop by replacing the resources.arsc in the compiled apk by the one from the original resources.arsc. They differ in size by a few kilobytes.

STEP BY STEP

1. Using APK Multi-Tools, use option

. Go to Projects folder and copy the resources.arsc file. This is the original file you shall place in the compiled app.

2. Compile as usual the modified mediatek-res app.

3. Go to '/Build/apk' folder and replace the resources.arsc therein with the one from setp 1.

4. Compile a second time.

5. Your apk will be able to boot and run ok now.

Because I am not very well versed with apktool and its inner workings, I don't know why this errors came up. I know this is a work-around, but for now it will have to do.

If this post saves you a few hours/days/weeks of research, hit thanks!!