Recompiling MIUI APKs

Discussion in 'Question & Answers' started by quaff, Apr 7, 2012.

  1. quaff

    quaffMembers

    Jun 23, 2011
    16
    1
    13
    I'm trying to recompile MiuiSystemUI.apk, I've gotten it to decompile etc, and recompile works fine. But MIUI doesn't seem to like my recompiled version.

    How I decompiled and recompiled:

    apktool if framework-res.apk
    apktool if framework-miui-res.apk
    apktool d MiuiSystemUI.apk
    ... made changes ...
    apktool b MiuiSystemUI MiuiSystemUI.apk

    Any one know what I'm missing or doing wrong?

    Thanks!!


    EDIT: Forgot to mention, I also decompiled then recompiled MiuiSystemUI.apk without changing anything, and it didn't work either :/
     
  2. fergie716

    fergie716Staff Developer

    Aug 8, 2011
    171
    51
    38
    Male
    Can you post your apktool log?

    What errors are you getting?

    Are you on Windows?

    Sent from my Nexus S 4G using Tapatalk 2 Beta-6
     
  3. quaff

    quaffMembers

    Jun 23, 2011
    16
    1
    13
    I'm not getting any errors, it recompiles fine. But here is the log:

    Code:
    # apktool if framework-res.apk
    I: Framework installed to: /home/quaff/apktool/framework/1.apk
    # apktool if framework-miui-res.apk
    I: Framework installed to: /home/quaff/apktool/framework/3.apk
    # apktool d MiuiSystemUI-orig.apk
    I: Baksmaling...
    I: Loading resource table...
    I: Loaded.
    I: Loading resource table from file: /home/quaff/apktool/framework/1.apk
    I: Loaded.                                                                                       
    I: Loading resource table from file: /home/quaff/apktool/framework/3.apk                         
    I: Loaded.                                                                                       
    I: Decoding file-resources...                                                                     
    I: Decoding values*/* XMLs...
    I: Done.
    I: Copying assets and libs...
    # apktool b MiuiSystemUI-orig MiuiSystemUI.apk
    I: Checking whether sources has changed...
    I: Smaling...
    I: Checking whether resources has changed...
    I: Building resources...
    I: Building apk file...
    #
    I tried this on both Windows and Linux, can't seem to get the apk to build on Mac OS X tho.
     
  4. quaff

    quaffMembers

    Jun 23, 2011
    16
    1
    13
    This was a direct recompile, no changes were made. The file size of the original and the newly compiled MiuiSystemUI.apk is different :/

    Code:
    # ls -al
    total 7432
    drwxrwxr-x 3 quaff quaff    4096 2012-04-06 18:29 .
    drwxr-xr-x 7 quaff quaff    4096 2012-04-06 18:28 ..
    -rw-rw-r-- 1 quaff quaff 1090286 2008-02-29 02:33 framework-miui-res.apk
    -rw-rw-r-- 1 quaff quaff 4333364 2008-02-29 02:33 framework-res.apk
    -rw-rw-r-- 1 quaff quaff 1014080 2012-04-06 18:29 MiuiSystemUI.apk
    drwxrwxr-x 6 quaff quaff    4096 2012-04-06 18:29 MiuiSystemUI-orig
    -rw-r--r-- 1 quaff quaff 1152800 2012-04-06 18:28 MiuiSystemUI-orig.apk
     
  5. fergie716

    fergie716Staff Developer

    Aug 8, 2011
    171
    51
    38
    Male
    It just stalls out then?

    Here's my apktool set up if you wanna try (Windows 7)

    Just un zip and place contents in your apktool folder

    I was able to decompile/recompile latest apk's and jar's from todays update (Nexus S ICS) so hopefully this helps

    Download

    Just make sure you backup your current apktool set up because I think this only works for 4.0.4
     
  6. quaff

    quaffMembers

    Jun 23, 2011
    16
    1
    13
    Nope, it finishes the compile without any errors. When I adb push it to /system/app and reboot, navigation bar, my status bar and whatever else is related to MiuiSystemUI.apk is missing.

    I just tried it with your apktool and I'm having the same issues :/
     
  7. fergie716

    fergie716Staff Developer

    Aug 8, 2011
    171
    51
    38
    Male
    Are you signing it?

    Needs META-INF Folder, apktool does not add it

    So you can either take the AndroidManifest.xml and META-INF folder from original apk and place it in your modified one or use a tool like ApkManager to sign the apk and make a flashable
     
  8. quaff

    quaffMembers

    Jun 23, 2011
    16
    1
    13
    Ah! That's the step I was missing!

    Thanks, it works now :D
     
  9. socekin

    socekinMembers

    Mar 17, 2012
    38
    1
    18
    Male
    hi, i use your tool,but i can't build framework-miui-res.apk, here is the errors
    here is my setup:
    apktool if framework-res.apk
    apktool if framework-miui-res.apk
    apktool d framework-miui-res.apk
    ... made no changes ...
    apktool b framework-miui-res

    and ideas? thanks
    --------------------------------------

    ml:592: error: Public symbol id/android_alwaysUse declared here is not defined.
    C:\Users\Jayziva\Desktop\apktool-miui-ics\framework-miui-res\res\values\public.x
    ml:594: error: Public symbol id/android_banner declared here is not defined.
    C:\Users\Jayziva\Desktop\apktool-miui-ics\framework-miui-res\res\values\public.x
    ml:598: error: Public symbol id/android_body declared here is not defined.
    C:\Users\Jayziva\Desktop\apktool-miui-ics\framework-miui-res\res\values\public.x
    ml:593: error: Public symbol id/android_clearDefaultHint declared here is not de
    fined.
    C:\Users\Jayziva\Desktop\apktool-miui-ics\framework-miui-res\res\values\public.x
    ml:595: error: Public symbol id/android_mount_button declared here is not define
    d.
    C:\Users\Jayziva\Desktop\apktool-miui-ics\framework-miui-res\res\values\public.x
    ml:591: error: Public symbol id/android_split_action_bar declared here is not de
    fined.


    C:\Users\Jayziva\Desktop\apktool-miui-ics\framework-miui-res\res\values\public.x
    ml:599: error: Public symbol id/visible_panel declared here is not defined.
    C:\Users\Jayziva\Desktop\apktool-miui-ics\framework-miui-res\res\values\public.x
    ml:1188: error: Public symbol xml/android_apns declared here is not defined.
    Exception in thread "main" brut.androlib.AndrolibException: brut.common.BrutExce
    ption: could not exec command: [aapt, p, -F, C:\Users\Jayziva\AppData\Local\Temp
    \APKTOOL6131001091138339152.tmp, -x, -I, C:\Users\Jayziva\apktool\framework\1.ap
    k, -S, C:\Users\Jayziva\Desktop\apktool-miui-ics\framework-miui-res\res, -M, C:\
    Users\Jayziva\Desktop\apktool-miui-ics\framework-miui-res\AndroidManifest.xml]
    at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav
    a:193)
    at brut.androlib.Androlib.buildResourcesFull(Androlib.java:301)
    at brut.androlib.Androlib.buildResources(Androlib.java:248)
    at brut.androlib.Androlib.build(Androlib.java:171)
    at brut.androlib.Androlib.build(Androlib.java:154)
    at brut.apktool.Main.cmdBuild(Main.java:182)
    at brut.apktool.Main.main(Main.java:67)
    Caused by: brut.common.BrutException: could not exec command: [aapt, p, -F, C:\U
    sers\Jayziva\AppData\Local\Temp\APKTOOL6131001091138339152.tmp, -x, -I, C:\Users
    \Jayziva\apktool\framework\1.apk, -S, C:\Users\Jayziva\Desktop\apktool-miui-ics\
    framework-miui-res\res, -M, C:\Users\Jayziva\Desktop\apktool-miui-ics\framework-
    miui-res\AndroidManifest.xml]
    at brut.util.OS.exec(OS.java:83)
    at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav
    a:191)
    ... 6 more

    C:\Users\Jayziva\Desktop\apktool-miui-ics>
     
  10. iBotPeaches

    iBotPeachesScript Gatekeeper

    Oct 31, 2011
    3,811
    1,115
    335
    Kansas
    ^ Looks like your aapt is out of date.
     
  11. socekin

    socekinMembers

    Mar 17, 2012
    38
    1
    18
    Male
    aapt is the latest one。
     
  12. iBotPeaches

    iBotPeachesScript Gatekeeper

    Oct 31, 2011
    3,811
    1,115
    335
    Kansas
    Then it looks like apktool is screwing up that APK.

    My version 1.4.5 might fix it, but its not for the public yet.
     
  13. socekin

    socekinMembers

    Mar 17, 2012
    38
    1
    18
    Male
    can you send it to me? thanks,socekin@gmail.com
     
  14. iBotPeaches

    iBotPeachesScript Gatekeeper

    Oct 31, 2011
    3,811
    1,115
    335
    Kansas
    I'm not distributing it yet. Otherwise people will share it, then we might have a higher version apktool, but might have some huge underlying bugs.
     
  15. Acid

    AcidScripting Ninja
    Staff Member

    Aug 20, 2011
    2,726
    743
    245
    Male
    To compile framework-miui-res.apk you need another framework installed with Id 2 like com.htc.resources.apk from HTC. Then you need to correct errors in /values. If you do it right everything will work.

    Sent from my Nexus S using Tapatalk 2
     
  16. socekin

    socekinMembers

    Mar 17, 2012
    38
    1
    18
    Male
    where can i find the framework installed with Id 2?thanks
     
  17. Acid

    AcidScripting Ninja
    Staff Member

    Aug 20, 2011
    2,726
    743
    245
    Male
    Just download rom for any HTC. Like the newest miuiandroid_Sensation rom. It will be in /system/framework.
    Use com.htc.resources.apk for compilation with every device you do. This frameworks is just to be installed. You can't add this framework to translation pack. When you install this framework, apktool will have proper IDs installed so it will pass the compilation.
     
  18. socekin

    socekinMembers

    Mar 17, 2012
    38
    1
    18
    Male
    i try it,still the problem
     
  19. Acid

    AcidScripting Ninja
    Staff Member

    Aug 20, 2011
    2,726
    743
    245
    Male
    Do you have still the same error like you posted? The error is telling you about ids. So check /res/values/ids.xml for bugs in strings. Do you corrected those errors right?

    Ok nevermind. Just put the content of zip I've attached to this post to framework-miui-res.apk before compilation.

    Files are actual til 2.4.13.
     

    Attached Files:

  20. 181charan

    181charanMembers

    Jun 13, 2012
    1
    0
    21
    Male
    Bangalore, India
    I am still getting this error while recompiling framework-miui-res.apk! :(

    Code:
    E:\tool>apktool b frameworkmiui
    W: Could not find sources
    I: Checking whether resources has changed...
    I: Building resources...
    Included base package ID 2 already in use!
    Exception in thread "main" brut.androlib.AndrolibException: brut.common.BrutExce
    ption: could not exec command: [aapt, p, -F, E:\Users\Airwalk\AppData\Local\Temp
    \APKTOOL7604413565760849728.tmp, -x, -I, E:\Users\Airwalk\apktool\framework\1.ap
    k, -I, E:\Users\Airwalk\apktool\framework\2.apk, -I, E:\Users\Airwalk\apktool\fr
    amework\3.apk, -I, E:\Users\Airwalk\apktool\framework\4.apk, -I, E:\Users\Airwal
    k\apktool\framework\5.apk, -S, E:\tool\frameworkmiui\res, -M, E:\tool\frameworkm
    iui\AndroidManifest.xml]
            at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav
    a:193)
            at brut.androlib.Androlib.buildResourcesFull(Androlib.java:301)
            at brut.androlib.Androlib.buildResources(Androlib.java:248)
            at brut.androlib.Androlib.build(Androlib.java:171)
            at brut.androlib.Androlib.build(Androlib.java:154)
            at brut.apktool.Main.cmdBuild(Main.java:182)
            at brut.apktool.Main.main(Main.java:67)
    Caused by: brut.common.BrutException: could not exec command: [aapt, p, -F, E:\U
    sers\Airwalk\AppData\Local\Temp\APKTOOL7604413565760849728.tmp, -x, -I, E:\Users
    \Airwalk\apktool\framework\1.apk, -I, E:\Users\Airwalk\apktool\framework\2.apk,
    -I, E:\Users\Airwalk\apktool\framework\3.apk, -I, E:\Users\Airwalk\apktool\frame
    work\4.apk, -I, E:\Users\Airwalk\apktool\framework\5.apk, -S, E:\tool\frameworkm
    iui\res, -M, E:\tool\frameworkmiui\AndroidManifest.xml]
            at brut.util.OS.exec(OS.java:83)
            at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav
    a:191)
            ... 6 more
    What am i doing wrong?? Plz help!! :(
     
  21. iBotPeaches

    iBotPeachesScript Gatekeeper

    Oct 31, 2011
    3,811
    1,115
    335
    Kansas
    Strange error. Its like your windows computer won't let go of the hold on framework 2.apk.
     

Share Our Site