[Guide] How to port Stock 2.3.6 apps to cm7

Search This thread

mohamedrashad

Senior Member
Nov 15, 2012
1,087
618
26
ismailia
Warning:

This guide isn't orginally by me, I found it on internet and posting (with some edits) here to help people

The original post : http://epiccm.blogspot.com/2012/01/porting-touchwiz-apps-for-cm7.html



Many stock Samsung apps are awesome and beautifully looking, also cyanogen mod is fast and high customizable, you dont need to sacrfice CM& for good looking apps anymore


STEPS:


1- get your desired App from System/app + twframework.jar and twframework-res.apk from System/framework

2- Decompile all of them Using APK Manager OR Apktool OR Virtous Ten Studio or any other apps

Guide for decompile,compile : HERE

3- Remove the library dependence from the AndroidManifest.xml
The line looks like this:

Code:

and remove any lines contain ‘com.device.samsung’

This to make it install on non samsung roms


4- Copy the twframework code into the app source.

‘twframework.jar.out/smali/’

The app now contains both its own code, and all the needed TouchWiz code. There’s a small chance it might work if you recompile it now, but it probably also needs resources
.

5-Update the resources

a. Add the needed files/parts
search for any ‘@touchwiz:’ parts in any xml file under res/.
Next, you will need to merge everything under /res/ from the twframework-res.apk.
Copy over anything that doesn’t already exist. Files under /res/values/ (Except public.xml) will need to be merged, meaning insert all the values from the framework into the app, before the closing tag (Keep the XML valid). If your missing any resources, re-compiling the APK will fail

b. Remove the touchwiz references

Replace every ‘@touchwiz:’ with just an ‘@’

Example :
Code:
@touchwiz:color/

to 

@color/


Copied directly from OP :
There are some calls to IDs in the 0x20 range, this is an issue because as far as I know, the 0x20 range can only be provided by the system somehow. For the Calendar app, I had to remove setIcon calls in a few activities to prevent ResourceNotFound exceptions.
If you remove them, then some things like images might not work. I also found that just removing them can cause random NullPointer errors.

Note: While working on the Task Manager, it became more complex. I had to update the old 0x20 references to the references within the new package.
After the resources are added, decompile it again, so the added resources show up in the /res/values/public.xml
Search for the old 0x20 value, and update it to the new value. If you include the /smali/touchwiz/ directory, then you can just search for the hex value and you will get the name of it from the TW R.smali files, and you can find the updated hex value in the /res/value/public.xml file


6. Re-compile

7. Sign the apk using platform key or testkey from HERE


Most apps uses testkey but if you had any permission error, use platform key or search google for the error


8. Install

adb push /system/app/

OR

using system app installer

OR

using any root explorer


Credits :
-Original poster
-Me, for simplifing it
 
Last edited:

mohamedrashad

Senior Member
Nov 15, 2012
1,087
618
26
ismailia
Well, I had it in my mind everytime :p but never tried doing it... #laziness

Anyways, this IS usefull :good:

Its a great honor for me that a good developer like you admires my work :D:D

On a side note : many devs ported stock apps (generally clock widget and launcher and task manager) to CM7 but no one ever shared, I don't like those who don't share their experiences :p

Sent from my GT-S5360 using Tapatalk 2
 

Top Liked Posts

  • There are no posts matching your filters.
  • 8
    Warning:

    This guide isn't orginally by me, I found it on internet and posting (with some edits) here to help people

    The original post : http://epiccm.blogspot.com/2012/01/porting-touchwiz-apps-for-cm7.html



    Many stock Samsung apps are awesome and beautifully looking, also cyanogen mod is fast and high customizable, you dont need to sacrfice CM& for good looking apps anymore


    STEPS:


    1- get your desired App from System/app + twframework.jar and twframework-res.apk from System/framework

    2- Decompile all of them Using APK Manager OR Apktool OR Virtous Ten Studio or any other apps

    Guide for decompile,compile : HERE

    3- Remove the library dependence from the AndroidManifest.xml
    The line looks like this:

    Code:

    and remove any lines contain ‘com.device.samsung’

    This to make it install on non samsung roms


    4- Copy the twframework code into the app source.

    ‘twframework.jar.out/smali/’

    The app now contains both its own code, and all the needed TouchWiz code. There’s a small chance it might work if you recompile it now, but it probably also needs resources
    .

    5-Update the resources

    a. Add the needed files/parts
    search for any ‘@touchwiz:’ parts in any xml file under res/.
    Next, you will need to merge everything under /res/ from the twframework-res.apk.
    Copy over anything that doesn’t already exist. Files under /res/values/ (Except public.xml) will need to be merged, meaning insert all the values from the framework into the app, before the closing tag (Keep the XML valid). If your missing any resources, re-compiling the APK will fail

    b. Remove the touchwiz references

    Replace every ‘@touchwiz:’ with just an ‘@’

    Example :
    Code:
    @touchwiz:color/
    
    to 
    
    @color/


    Copied directly from OP :
    There are some calls to IDs in the 0x20 range, this is an issue because as far as I know, the 0x20 range can only be provided by the system somehow. For the Calendar app, I had to remove setIcon calls in a few activities to prevent ResourceNotFound exceptions.
    If you remove them, then some things like images might not work. I also found that just removing them can cause random NullPointer errors.

    Note: While working on the Task Manager, it became more complex. I had to update the old 0x20 references to the references within the new package.
    After the resources are added, decompile it again, so the added resources show up in the /res/values/public.xml
    Search for the old 0x20 value, and update it to the new value. If you include the /smali/touchwiz/ directory, then you can just search for the hex value and you will get the name of it from the TW R.smali files, and you can find the updated hex value in the /res/value/public.xml file


    6. Re-compile

    7. Sign the apk using platform key or testkey from HERE


    Most apps uses testkey but if you had any permission error, use platform key or search google for the error


    8. Install

    adb push /system/app/

    OR

    using system app installer

    OR

    using any root explorer


    Credits :
    -Original poster
    -Me, for simplifing it
    2
    Well, I had it in my mind everytime :p but never tried doing it... #laziness

    Anyways, this IS usefull :good:

    Its a great honor for me that a good developer like you admires my work :D:D

    On a side note : many devs ported stock apps (generally clock widget and launcher and task manager) to CM7 but no one ever shared, I don't like those who don't share their experiences :p

    Sent from my GT-S5360 using Tapatalk 2
    1
    Well this is useful! :D
    1
    yeah finaly i got this
    many thanks sir
    1
    Well, I had it in my mind everytime :p but never tried doing it... #laziness

    Anyways, this IS usefull :good: