[GUIDE][Updated 19/04/12] PatchROM - MIUI 2.3 and 4.0 Porting

Search This thread

ThePCGuy

Member
Jun 3, 2011
27
47
Santa Rita do Sapucaí
Hello guys!

MIUI recently opensourced a set of tools made for porting it's ROM to other devices. Although I haven't managed to build a working ROM for our dear X8, here's a little guide on how it (kinda) works, maybe it helps someone.

Any contribution is welcome :D

Here's what I've found of PatchROM:

Edit: MIUI changed the way to download the source code. Now you can use PatchROM on Android 2.3 and 4.0!

And make sure you have apktool installed.

The overall proccess looks like this:
  1. Download the tools
  2. Get an Gingerbread/ICS ROM to install MIUI stuff;
  3. Create the required file structure
  4. Change the Makefile
  5. Apply MIUI changes to the selected ROM
  6. Flash it! :D

STEP 1: Downloading the tools

If you want to patch a 2.3 ROM, just click the 'ZIP' button on the PatchROM Github: https://github.com/MiCode/legacy-patchrom

If you want to patch a 4.0 ROM, do the following:

Supposing you are on Linux:

  1. Make sure you have the Android SDK installed and on your PATH.
  2. Install repo following this guide. Do only the 'Installing repo' section.

Then, create a new folder (in my case, ~/patchrom), enter it and type the following commands:
Code:
repo init -u git://github.com/MiCode/patchrom.git -b ics
repo sync

This command will download the PatchROM system to the ~/patchrom folder.

STEP 2: Choosing the ROM
The PatchROM docs recommend that we use a stock AOSP ROM from the device manufacturer, but there's no official Gingerbread or ICS for our device, so we need to use one of the CM7/CM9 roms. Use an CM7 rom if you are using patchrom-legacy, and use an CM9 rom if you are using the regular patchrom. Make sure you use an deodexed rom or deodex your rom.

The rest of this guide was tested on patchrom-legacy (2.3), not tested on the regular patchrom for 4.0.

STEP 3: Creating the file structure
To port, we need to create a folder inside the PatchROM root directory for our device. There's an example device for the Samsung Galaxy S on the i9000 folder, we'll use that as a base. I created a folder called 'shakira' and copied the makefile file from the i9000 folder and the MiniCM7 zip to it.

You also need to decompile the following APK files and put the resulting folder on the 'shakira' folder:

  • /system/framework/android.policy.jar
  • /system/framework/framework.jar
  • /system/framework/framework-res.apk
  • /system/app/SystemUI.apk
  • /system/framework/services.jar
  • and the apps defined on the 'local-modified-apps' below
STEP 4: Editing the Makefile
The makefile has the following structure:
Code:
#
# Makefile for i9100
#

# The original zip file, MUST be specified by each product
local-zip-file     := I9100ZCKJ1.zip

# The output zip file of MIUI rom, the default is porting_miui.zip if not specified
local-out-zip-file := MIUI_9100.zip

# All apps from original ZIP, but has smali files chanded
local-modified-apps := LogsProvider Phone MediaProvider Settings

# All apks from MIUI execept MIUISystemUI and framework-miui-res.apk
local-miui-apps     := Contacts ContactsProvider Mms TelephonyProvider ThemeManager Launcher2 \
     DownloadProvider TelocationProvider Notes Music Torch DownloadProviderUi Updater

# All apps need to be removed from original ZIP file
local-remove-apps   := AlipayGphone AmsComposer AndroidQQ_Samsung_Seine BuddiesNow cooldict glyder2 \
    ImgoTV iReader kaixin001 Memo MiniDiary MinimalHome mreader PressReader ReadersHub Renren   \
    Sinamicroblog SinaNews SinaStock SinaWeather SocialHub Tencentmicroblog  \
    TomEbook Tonghuashun TouchWiz30Launcher Youku_Samsung_seine MusicPlayer \
    MediaHub PhotoRetouching VideoEditor thinkdroid QYVideoClient \
    Days DigitalClock Dlna DualClock Email EmailWidget FTC FTM FTS Kobo \
    Microbesgl Navigator PostIt Protips QuickSearchBox SamsungApps SamsungAppsUNA3 \
    SamsungIM SamsungWidget_ProgramMonitor SecretWallpaper1 SecretWallpaper2 \
    SevenEngine SnsAccountKx SnsAccountRr SnsDisclaimer SnsImageCache SnsProvider \
    Tasks TasksProvider Term TrimApp TwCalendarAppWidget Zinio \
    samsungappswidget syncmldm viva_tts

# To include the local targets before and after zip the final ZIP file, 
# and the local-targets should:
# (1) be defined after including porting.mk if using any global variable(see porting.mk)
# (2) the name should be leaded with local- to prevent any conflict with global targets
local-pre-zip := local-zip-misc
local-after-zip:= local-test

# The local targets after the zip file is generated, could include 'zip2sd' to 
# deliver the zip file to phone, or to customize other actions

include $(PORT_BUILD)/porting.mk

# To define any local-target
local-zip-misc:
	cp misc/com.google.android.maps.jar $(ZIP_DIR)/system/framework/
	@echo Add google apks
	cp misc/apk/* $(ZIP_DIR)/system/app/
	@echo Replace build.prop
	cp misc/build.prop $(ZIP_DIR)/system/build.prop

local-test:
	echo "an example action"

Here's how it works:

  • The 'local-zip-file' should match your rom's ZIP (on my case MiniCM-2.1.ZIP)
  • The 'local-out-zip-file' is the MIUI ROM output name (put any name you want here)
  • The 'local-modified-apps', as pointed by MisterGT, 'are those that are required from the original rom because they do important stuff (like Phone.apk communicates with your phone's radio). Thus these can not be easily copied from miui but have to be modified.'
  • The 'local-miui-apps' point to the MIUI files; I didn't changed those
  • The 'local-remove-apps' indicates apps to be removed from the ROM
  • As MisterGT also pointed out here (thanks mate!), the "local-pre-zip := local-zip-misc" line executes the code block before the zip is done, and the "local-after-zip:= local-test" executes the code block after the zip is done.

STEP 5: Apply MIUI Changes
To apply the MIUI changes on the choosen ROM, type those commands in the root of PatchROM:
Code:
source build/envsetup.sh
cd shakira # CHANGE THIS LINE TO MATCH THE FOLDER YOU CREATED IN STEP 3
make

Now it should decompile the ROM and merge the ROM's smali files with the MIUI files, and create an ZIP file with the MIUI rom, but I got some errors decompiling SystemUI.apk :( maybe some of the awesome devs there can solve this :D

EDIT: The 'sh build/envsetup.sh' command was wrong; it's actually 'source build/envsetup.sh'. Fixed it above. That fixes the porting.mk errors :D

SOURCES:
PDF in the docs folder on PatchROM (thank you Google Translate!)
Github README
 
Last edited:

ThePietn1

Senior Member
Jan 1, 2011
159
151
Eernegem
It might be a stupid question, but did you deodex the files? MiniCM7 is fully odexed for better loading times, but most probably this won't work with those files...
 
Mar 9, 2010
41
1
Kurnool
"You also need to decompile the following APK files and put the resulting folder on the 'shakira' folder:
/system/framework/android.policy.jar
/system/framework/framework.jar
/system/framework/framework-res.apk
/system/app/SystemUI.apk
/system/framework/services.jar
and the apps defined on the 'local-modified-apps' below"
Are these files from i9100 folder?, How to decompile?
 

ThePCGuy

Member
Jun 3, 2011
27
47
Santa Rita do Sapucaí
"You also need to decompile the following APK files and put the resulting folder on the 'shakira' folder:
/system/framework/android.policy.jar
/system/framework/framework.jar
/system/framework/framework-res.apk
/system/app/SystemUI.apk
/system/framework/services.jar
and the apps defined on the 'local-modified-apps' below"
Are these files from i9100 folder?, How to decompile?

Those files are from the rom .zip. To decompile them, make sure that you have apktool installed and type:
Code:
apktool d <file>
This command will spit an folder, move that folder to the 'shakira' folder.

EDIT: Just contacted a mod to move this thread to the Development section
 
Last edited:

Coudy73

Senior Member
Nov 27, 2011
85
19
but what about arm v6? i thought that miui for arm v7 devices. if so then we have one more problem
 
Mar 9, 2010
41
1
Kurnool
Followed exactly what you wrote.. but got the following

makefile:41: /porting.mk: No such file or directory
make: *** No rule to make target `/porting.mk'. Stop.
 

droidx8

Senior Member
Oct 14, 2011
355
73
Yep, but Adobe Flash is for ARMv7 too and we are an Adobe Flash Player for ARMv6

+1
Good point. I don't wanna say nothing is unavaliable, but we can port some ROMs and apps that we haven't got basically (just see Froyo, GingerBread and ICS.SE left x8/w8 with sh!tty eclair, and now we have these great ROMs on our little device, thanks to devs for them).

Sent from my E15i using xda premium
 
  • Like
Reactions: TimeWasterNL

lucastan96

Senior Member
Dec 9, 2011
2,945
2,083
27
Malacca
Go devs! I can really see the improved traffic when this thread is moved to development section!

Hit the THANKS button if I helped!!

Sent from my W8 using Tapatalk
 
  • Like
Reactions: Mkey01

Top Liked Posts

  • There are no posts matching your filters.
  • 31
    Hello guys!

    MIUI recently opensourced a set of tools made for porting it's ROM to other devices. Although I haven't managed to build a working ROM for our dear X8, here's a little guide on how it (kinda) works, maybe it helps someone.

    Any contribution is welcome :D

    Here's what I've found of PatchROM:

    Edit: MIUI changed the way to download the source code. Now you can use PatchROM on Android 2.3 and 4.0!

    And make sure you have apktool installed.

    The overall proccess looks like this:
    1. Download the tools
    2. Get an Gingerbread/ICS ROM to install MIUI stuff;
    3. Create the required file structure
    4. Change the Makefile
    5. Apply MIUI changes to the selected ROM
    6. Flash it! :D

    STEP 1: Downloading the tools

    If you want to patch a 2.3 ROM, just click the 'ZIP' button on the PatchROM Github: https://github.com/MiCode/legacy-patchrom

    If you want to patch a 4.0 ROM, do the following:

    Supposing you are on Linux:

    1. Make sure you have the Android SDK installed and on your PATH.
    2. Install repo following this guide. Do only the 'Installing repo' section.

    Then, create a new folder (in my case, ~/patchrom), enter it and type the following commands:
    Code:
    repo init -u git://github.com/MiCode/patchrom.git -b ics
    repo sync

    This command will download the PatchROM system to the ~/patchrom folder.

    STEP 2: Choosing the ROM
    The PatchROM docs recommend that we use a stock AOSP ROM from the device manufacturer, but there's no official Gingerbread or ICS for our device, so we need to use one of the CM7/CM9 roms. Use an CM7 rom if you are using patchrom-legacy, and use an CM9 rom if you are using the regular patchrom. Make sure you use an deodexed rom or deodex your rom.

    The rest of this guide was tested on patchrom-legacy (2.3), not tested on the regular patchrom for 4.0.

    STEP 3: Creating the file structure
    To port, we need to create a folder inside the PatchROM root directory for our device. There's an example device for the Samsung Galaxy S on the i9000 folder, we'll use that as a base. I created a folder called 'shakira' and copied the makefile file from the i9000 folder and the MiniCM7 zip to it.

    You also need to decompile the following APK files and put the resulting folder on the 'shakira' folder:

    • /system/framework/android.policy.jar
    • /system/framework/framework.jar
    • /system/framework/framework-res.apk
    • /system/app/SystemUI.apk
    • /system/framework/services.jar
    • and the apps defined on the 'local-modified-apps' below
    STEP 4: Editing the Makefile
    The makefile has the following structure:
    Code:
    #
    # Makefile for i9100
    #
    
    # The original zip file, MUST be specified by each product
    local-zip-file     := I9100ZCKJ1.zip
    
    # The output zip file of MIUI rom, the default is porting_miui.zip if not specified
    local-out-zip-file := MIUI_9100.zip
    
    # All apps from original ZIP, but has smali files chanded
    local-modified-apps := LogsProvider Phone MediaProvider Settings
    
    # All apks from MIUI execept MIUISystemUI and framework-miui-res.apk
    local-miui-apps     := Contacts ContactsProvider Mms TelephonyProvider ThemeManager Launcher2 \
         DownloadProvider TelocationProvider Notes Music Torch DownloadProviderUi Updater
    
    # All apps need to be removed from original ZIP file
    local-remove-apps   := AlipayGphone AmsComposer AndroidQQ_Samsung_Seine BuddiesNow cooldict glyder2 \
        ImgoTV iReader kaixin001 Memo MiniDiary MinimalHome mreader PressReader ReadersHub Renren   \
        Sinamicroblog SinaNews SinaStock SinaWeather SocialHub Tencentmicroblog  \
        TomEbook Tonghuashun TouchWiz30Launcher Youku_Samsung_seine MusicPlayer \
        MediaHub PhotoRetouching VideoEditor thinkdroid QYVideoClient \
        Days DigitalClock Dlna DualClock Email EmailWidget FTC FTM FTS Kobo \
        Microbesgl Navigator PostIt Protips QuickSearchBox SamsungApps SamsungAppsUNA3 \
        SamsungIM SamsungWidget_ProgramMonitor SecretWallpaper1 SecretWallpaper2 \
        SevenEngine SnsAccountKx SnsAccountRr SnsDisclaimer SnsImageCache SnsProvider \
        Tasks TasksProvider Term TrimApp TwCalendarAppWidget Zinio \
        samsungappswidget syncmldm viva_tts
    
    # To include the local targets before and after zip the final ZIP file, 
    # and the local-targets should:
    # (1) be defined after including porting.mk if using any global variable(see porting.mk)
    # (2) the name should be leaded with local- to prevent any conflict with global targets
    local-pre-zip := local-zip-misc
    local-after-zip:= local-test
    
    # The local targets after the zip file is generated, could include 'zip2sd' to 
    # deliver the zip file to phone, or to customize other actions
    
    include $(PORT_BUILD)/porting.mk
    
    # To define any local-target
    local-zip-misc:
    	cp misc/com.google.android.maps.jar $(ZIP_DIR)/system/framework/
    	@echo Add google apks
    	cp misc/apk/* $(ZIP_DIR)/system/app/
    	@echo Replace build.prop
    	cp misc/build.prop $(ZIP_DIR)/system/build.prop
    
    local-test:
    	echo "an example action"

    Here's how it works:

    • The 'local-zip-file' should match your rom's ZIP (on my case MiniCM-2.1.ZIP)
    • The 'local-out-zip-file' is the MIUI ROM output name (put any name you want here)
    • The 'local-modified-apps', as pointed by MisterGT, 'are those that are required from the original rom because they do important stuff (like Phone.apk communicates with your phone's radio). Thus these can not be easily copied from miui but have to be modified.'
    • The 'local-miui-apps' point to the MIUI files; I didn't changed those
    • The 'local-remove-apps' indicates apps to be removed from the ROM
    • As MisterGT also pointed out here (thanks mate!), the "local-pre-zip := local-zip-misc" line executes the code block before the zip is done, and the "local-after-zip:= local-test" executes the code block after the zip is done.

    STEP 5: Apply MIUI Changes
    To apply the MIUI changes on the choosen ROM, type those commands in the root of PatchROM:
    Code:
    source build/envsetup.sh
    cd shakira # CHANGE THIS LINE TO MATCH THE FOLDER YOU CREATED IN STEP 3
    make

    Now it should decompile the ROM and merge the ROM's smali files with the MIUI files, and create an ZIP file with the MIUI rom, but I got some errors decompiling SystemUI.apk :( maybe some of the awesome devs there can solve this :D

    EDIT: The 'sh build/envsetup.sh' command was wrong; it's actually 'source build/envsetup.sh'. Fixed it above. That fixes the porting.mk errors :D

    SOURCES:
    PDF in the docs folder on PatchROM (thank you Google Translate!)
    Github README
    4
    Guys, just updated the guide, now you can patch both GB and ICS!
    4
    Thanks, there is a screenshot. Superuser working, but I have to add permisions on zip (META-INF). I have to learning for test now, so you guys must to be patient!

    screenshot2012022217323.png



    Hope you like it! Cheers!
    3
    This myProject on LWW, but i dont know my x8:)
    device-2012-02-08-205100.png
    3
    I heard from somewhere that we could try to use Defy's official miui to help us in porting... Not sure if it works...

    Yup, but nobody care about port it to our phone. I'll install Linux on Saturnday, and try to port and boot it from this MIUI sources. Cheers.

    ...