How can I change the package name? - Android Q&A, Help & Troubleshooting

Hi everybody, I'm trying to make a soundboard to put on the android market. I downloaded a soundboard template from http://myandroidsoundboard.com/, and it works great except I don't know how to successfully change the package name from "com.soundboard" to something else without making the project go all "error" crazy.
I click the package name in the the package explorer and click refactor and I change the package name, but then everything becomes an error because the package name is now different. How can I change the package name successfully so I don't get errors everywhere?
Thank you.

You don't need to change package name of Java classes. You must change package name stored in AndroidManifest.xml and maybe some other files.

Brut.all said:
You don't need to change package name of Java classes. You must change package name stored in AndroidManifest.xml and maybe some other files.
Click to expand...
Click to collapse
I've gone through the android manifest file and I've changed everything there, but do you know what other files might need some changing? The only errors I see are coming from anything with the "R" next to it.

PrestoMovie said:
I've gone through the android manifest file and I've changed everything there, but do you know what other files might need some changing? The only errors I see are coming from anything with the "R" next to it.
Click to expand...
Click to collapse
I think it may be caused by the fact that after changing package name R.java file is generated in different Java package, but app code references original one. I see several ways, how to fix this: you could alter ant building process, use some refactoring tools to modify all references to R class or manually move generated R.java to proper place (and modify package declaration in it).
If you know, what I'm talking, then good. If you don't then it probably does not have sense to explain it further - it will take several pages of posting until you will get it.

Brut.all said:
I think it may be caused by the fact that after changing package name R.java file is generated in different Java package, but app code references original one. I see several ways, how to fix this: you could alter ant building process, use some refactoring tools to modify all references to R class or manually move generated R.java to proper place (and modify package declaration in it).
If you know, what I'm talking, then good. If you don't then it probably does not have sense to explain it further - it will take several pages of posting until you will get it.
Click to expand...
Click to collapse
which way would you say is this easiest? And would you be able to point me in the direction of a link that explains any of them well?

For what it's worth - archival value & others reading this thread now - a link to such info would be appreciated

PrestoMovie said:
which way would you say is this easiest? And would you be able to point me in the direction of a link that explains any of them well?
Click to expand...
Click to collapse
Ok, actually this can be done very simply ;-)
I think the best solution is to refactor code. Do you use some good IDE? Eclipse, Netbeans? If so you could use their refactoring tools, but it is also doable by simple find/replace. Just replace all occurrences of "import old.package.name.R;" in all *.java files by "import new.package.name.R;".
These are basics of Java/Android developing: if you know them, then you should have no problems

Brut.all said:
Ok, actually this can be done very simply ;-)
I think the best solution is to refactor code. Do you use some good IDE? Eclipse, Netbeans? If so you could use their refactoring tools, but it is also doable by simple find/replace. Just replace all occurrences of "import old.package.name.R;" in all *.java files by "import new.package.name.R;".
These are basics of Java/Android developing: if you know them, then you should have no problems
Click to expand...
Click to collapse
I'm using Eclipse. And thank you! Hopefully I can get it working now!

K, for some reason I'm only getting one error now in the androidmanifest.xml and it says "class com.soundboard.SoundBoard doesn't exist", but com.soundboard is no longer the package name.

bump bump bump.

bump.
I'm having the same problems. I've been able to create working .apk's but need to share it in the market and the market won't let me if the package name is the same thanks.

agentkalaw said:
bump.
I'm having the same problems. I've been able to create working .apk's but need to share it in the market and the market won't let me if the package name is the same thanks.
Click to expand...
Click to collapse
Advanced tasks require some knowledge. You must know, what is Android's package name and then changing it will be really easy thing to do.
Ahh and there is new "--rename-manifest-package" switch in newest aapt tool. I didn't test it, but it's official Android tool, so this should work.

PrestoMovie said:
K, for some reason I'm only getting one error now in the androidmanifest.xml and it says "class com.soundboard.SoundBoard doesn't exist", but com.soundboard is no longer the package name.
Click to expand...
Click to collapse
thanks for the help! I was actually able to change the package name and I'm having the exact same problem as the OP ^. I basically just need to edit the androidmanifest.xml file and i should be all set I tried searching on how to edit it after changing package names but no luck. any ideas? how do i edit androidmanifest.xml files to recognize the package name change? thanks again

Its been a long time since this post, but if it helps someone:
Issue: You have a source, you want to build 2 different apks from the same source, and be able to install both in the same device at the same time.
General Solution: Use a refactoring tool, like in eclipse, and rename all package names.
Better Solution: use aapt flag --rename-manifest-package. This does not require you change even a single line in the original source. Just this flag, and pass in a different package name, and whoa, you have a new apk with the different package name. I used it as follows, in the Android.mk:
LOCAL_AAPT_FLAGS := --rename-manifest-package new.package.name
Click to expand...
Click to collapse
Cheers

Related

Cooking related questions: folder icons and autoshortcut

I am continuing on my little cooking adventure but need some informtation that despite lots of searching I cannot find - perhaps someone could enlighten me on a coupls of issues.
1. I wish to assign different icons to my folders within programs - as others seem to do. How on earth do I do this? Yes, I can download .dlls, unsign them extract icons edit them and put them back and then resign them, but I cannot find my answer apart from the games folder.
I thought I would take a look at NRGs 2.0 ROM and see how he did it but I cannot locate his folder icons and so am confused even more.
2. Could someone explain how/what this autoshortcut things is and works as I keep seeing references to it when trying to rearrange shortcuts in the ROM.
Thanks for your time,
C.
For folder icons do the following if you have your dll already created. It sounds like you know how to do that part...
Create a new txt file
in the text file enter 50#"\Windows\yourdll -X" -X is the icon location. Rename the folder icon.lnk and place it in the folder. The 50 needs to be changed to something else and the first number should be something different and unique.
If you are cooking in a few icon.lnk files they need to be named like game folder icon and then with XML coding you need to rename them to icon.lnk
or what I do...
I place them all in a cab file and have the cab file run during customization.
Aaaaaaah (Moment of enlightenment)
Thank you so much, that answers a lot of questions for me. Time to get cracking I think.
Am I right in thinking I can add multiple files with the same name n the cab and simply install them to different directories - hence not bother with the renaming business?
Cheers
crazyC said:
Aaaaaaah (Moment of enlightenment)
Thank you so much, that answers a lot of questions for me. Time to get cracking I think.
Am I right in thinking I can add multiple files with the same name n the cab and simply install them to different directories - hence not bother with the renaming business?
Cheers
Click to expand...
Click to collapse
Yes you can...thats what I did before learning how to do it in XML or using the initflashfiles.txt files. An example of the txt file
Directory("\Windows\Start Menu\Programs\Tools\Rhodium Manila Tweak\"):-File("Icon.lnk","\Windows\Rhodium Manila Tweak Folder.lnk")
Oh, I assumed that I could not do this via the initflashfiles for some reason (assumed I would have a build problem due to multiple icon.lnk)
So, I could create a package with multiple *.lnks which then are renamed and put in the correct folders via the initflashfiles and then also include a custom dll in that package as well?
Thnaks again for the explanations.
crazyC said:
Oh, I assumed that I could not do this via the initflashfiles for some reason (assumed I would have a build problem due to multiple icon.lnk)
So, I could create a package with multiple *.lnks which then are renamed and put in the correct folders via the initflashfiles and then also include a custom dll in that package as well?
Thnaks again for the explanations.
Click to expand...
Click to collapse
Yes you can.
At0mAng said:
For folder icons do the following if you have your dll already created. It sounds like you know how to do that part...
Create a new txt file
in the text file enter 50#"\Windows\yourdll -X" -X is the icon location. Rename the folder icon.lnk and place it in the folder. The 50 needs to be changed to something else and the first number should be something different and unique.
Click to expand...
Click to collapse
While looking for something else I came across this thread and, while it's fairly old, I thought I should clarify two things, in case anyone else reads this.
First off, the <space> after "yourdll" should be a comma:yourdll.dll,-X​(N.B. I have to admit that I've never actually TRIED using a space instead of a comma, so a space might actually work. That said, the standard for .lnk files in Windows, whether mobile or desktop, is to use a comma.)
Secondly, the "<number>#" at the beginning of the icon.lnk file (or any .lnk file, for that matter) isn't arbitrary.
The number represents the number of characters following the "#". So, for example, the example string above, "50#"\Windows\yourdll,-X", should really be: 21#"\Windows\yourdll,-X".
Assuming that "-X" is "-32", the file should contain:22#"\Windows\yourdll,-32"​Another way to determine this is to look at the size of the file. Just subtract the characters of the number and the '#' itself from the size of the file. E.g., the above file would be 25 bytes.
(Once again, however, I have to include a caveat. The number doesn't actually matter. If the number before the '#' is wrong, the link will still work. I just wanted to explain what it's SUPPOSED to be.)
-geo

[Q] (Solved?) Change DEFAULT Homepage on Cooked Rom

Ok, got a bit of a problem here... I need to change the default homepage of the browser in a Rom I'm cooking... that means the homepage you get after a full factory reset, not that you set in the menu.... Please don't tell me how to set it in the browser menu....
A bit of background... I'm using a leaked Rom to build from. It was leaked from a Tracfone "LG-L95G" which is identical in every way to the LG-P999 aka T-Mobile G2X. Everything is working 100%. The only problem left from the "porting" is removing Tracfone as the default browser homepage.
This has turned out to be harder than I expected.
What I have done:
Browser.apk - the xml lists Google as the homepage. The word "tracfone" appears NOWHERE in the entire structure of the decompiled xml or values or even in the smali code.
SystemUI & framework-res - I've seen suggestions the homepage hides here. Can't find anything suggesting a setting to "tracfone"
flexdb - I really thought I had it kicked here. /system/etc/flex.db listed m.tracfone.com as the homepage for T-Mobile US. I changed all occurrences here to about:blank. I have also tried simply copying the flex.db from a P999 itself. Ie, removed ALL references to tracfone service and made it identical to a P999 in every way.
Ran grep -R tracfone * on the entire ROM.
Dug through tons of files by hand looking for any clue.
Unfortunately, even with all of that, do a wipe, open the browser, and you GET M.TRACFONE.COM again!
The word "tracfone" does not appear in build.prop, it does not appear in any init scripts, not even in the kernel scripts! Yet it comes back like Christine...
Does anyone have a clue where I could look next? Or failing that, even some way from an init.d script that I can overwrite the setting myself?
EDIT
Okay, I hate giving myself clues like this, but maybe this will help others (if I'm on the right track)...
Instead of doing a grep on the ROM from my PC, pre-install, I decided to actually hit up the RUNNING copy... so from adb into a Bash prompt on the phone itself, I ran a grep -r tracfone * and got the following result:
Code:
data/data/com.android.browser/databases/browser.db:Web page not availablehttp://m.tracfone.com/
data/data/com.android.browser/shared_prefs/com.android.browser_preferences.xml:<string name="homepage">http://m.tracfone.com</string>
data/data/com.lge.providers.flex/databases/flex.db:M77BRW_SETTINGDB_CURRENT_HOME_URL_Ihttp://m.tracfone.comhttp://m.tracfone.comI#
data/data/com.lge.providers.flex/databases/flex.db:=77BRW_SETTINGDB_HOME_URL_Ihttp://m.tracfone.comhttp://m.tracfone.como"
data/data/com.lge.providers.flex/databases/flex.db:=;;DATACOM_ACCOUNT_MMSC_0_Ihttp://mms.tracfone.comhttp://[email protected]
data/data/com.lge.providers.flex/databases/flex.db:;%%DATACOM_ACCOUNT_APN_0_Iwap.tracfonewap.tracfone:?
data/data/com.lge.providers.flex/databases/flex.db:M77BRW_SETTINGDB_CURRENT_HOME_URL_Ihttp://m.tracfone.comhttp://m.tracfone.comI
data/data/com.lge.providers.flex/databases/flex.db:=77BRW_SETTINGDB_HOME_URL_Ihttp://m.tracfone.comhttp://m.tracfone.como
data/data/com.lge.providers.flex/databases/flex.db:=;;DATACOM_ACCOUNT_MMSC_0_Ihttp://mms.tracfone.comhttp://mms.tracfone.com6%
data/data/com.lge.providers.flex/databases/flex.db:;%%DATACOM_ACCOUNT_APN_0_Iwap.tracfonewap.tracfone:$
Which is very odd.... considering that is NOT the content of the actual flex.db that was flashed to the phone. That leads to 1 question: Why isn't the phone respecting the flex.db? I've noticed other edits to the file (such as bookmarks) do not apply either. So it is being ignored at somepoint. FlexProvider.apk maybe? Or is something in the ROM still identifying the phone to T-Mobile as an MVNO device and they're pushing out an OTA flex update?
EDIT 2:
AHA! There's a flex.db *INSIDE* the FlexProvider.apk file! So it *IS* ignoring the one placed in /system/etc/flex/! Editing this should solve it - but I'm going to test test test to make sure.
lotherius said:
Ok, got a bit of a problem here... I need to change the default homepage of the browser in a Rom I'm cooking... that means the homepage you get after a full factory reset, not that you set in the menu.... Please don't tell me how to set it in the browser menu....
Click to expand...
Click to collapse
firstly to say interesting question!!
but I think it it not possible to change programmatically default homepage
this is a system app so will be signed by your provider let us suppose you find homepage location in code (could by result of a script parsing) by modifying source of that apk package how to solve signature problem ?!
if in .db file ...this file is created after flashing as a result of script parsing
not framework-res.apk better browser-res.apk if you have one
ruscan.calin said:
firstly to say interesting question!!
but I think it it not possible to change programmatically default homepage
this is a system app so will be signed by your provider let us suppose you find homepage location in code (could by result of a script parsing) by modifying source of that apk package how to solve signature problem ?!
if in .db file ...this file is created after flashing as a result of script parsing
not framework-res.apk better browser-res.apk if you have one
Click to expand...
Click to collapse
man use a ... editor...I can show you for fifty bucks
I was just curious about this tricky change (from your post) so thinking about Google motto don't be bad finally I have found but should recognize that I am bad at this time
here is solution
Actually, you can use an sqlite editor to change the values in the flex.db file... the problem I was having in the OP is that on an LG phone (maybe others?) the flex.db file is ignored and the one inside FlexProvider is used instead, so you have to edit both. You can add new locales the same way. No need to use a hex editor, as that would be much more difficult.
lotherius said:
Actually, you can use an sqlite editor to change the values in the flex.db file... the problem I was having in the OP is that on an LG phone (maybe others?) the flex.db file is ignored and the one inside FlexProvider is used instead, so you have to edit both. You can add new locales the same way. No need to use a hex editor, as that would be much more difficult.
Click to expand...
Click to collapse
maybe you are right regarding your phone... but also I prepare a custom rom for Alcatel ot-908 also to change default homepage was a problem for me but I did and simply works !

[Q] Converting Android Manifest.xml To readable, and vice-versa

Well, I was going to put an app up on the market for a seminar , [and yes, i did use that Google app Builder], so when i tried to upload it, it told me that some value in the AndroidManifest.xml had to be a 32-bit integer.
So, I opened up that apk, viewed the manifest.xml file, but it just looks like a load of gibberish to me -__-
Now, I'm a bit new to all of this, considering that 11th grade's keeping me a wee bit occupied, so I guess I'll need some help with this.
[And note: Umm. Do not flame me for coming up with this, I'm not blaming google's app builder, or anything like that, anyway]
I've come across a couple of things like apktool, but each time i run it, it tells me that there's a file in jre7 that cannot be opened, apparently. Touche :|
It's an old question, so I guess you don't care too much about the answer by now, but to help others with a similar query, there are 2 ways to read the AndroidManifest file if you have the apk file.
1) If you extract the apk to a PC, you can use the apktool or similar to get a text version of the AndroidManifest.xml file
2) Alternatively if you have the apk already installed on an Android device you can use something like App Detective (https://play.google.com/store/apps/details?id=com.zmarties.detective) to view the AndroidManifest.xml directly on the device, even for paid apps that you can't extract from the device. (Full disclosure, I wrote App Detective).

Help - Problem recompiling APP

Hello,
i am about to make some changes at a ROM for my Galaxy Nexus..
Since I want to change some Headlines in the Settings, I poured the Settings.apk.
I want to decompile and recompile it using apkt-tool. So i followed this guide. (I also tried auto apk tool)
Decompiling successed.
I edited the Settings_headers.xml.
Then i wanted to recompile the apk... But then the following error occurred:
http://www.pic-upload.de/view-15157159/Unbenannt.png.html
Any solutions? What should i do to make it work properly ?
Everytime i try to do it the same Error occurres.. i also tried to not edit anything and just recompile the apk to be sure that the mistake is not a mistake in the settings_headers.xml file.. Same Error.
I hope you can help me
Thanks in advance!
Its a system file,so you might need to add the framework-res.apk to the app,its sometimes needed to recompile,i believe you drag it into the command window.
I already did that with the framework-res.apk that was provided in the same ROM as the Settings.apk..
Same error..
Thois drives me crazy!
Most likely you need to update aapt. Install the latest sdk, and update the platform tools.
Sent from my Galaxy Nexus using xda premium
I have not even installed sdk...
so should i download install and pull the aapt to the folder where apk-tool is in?
Which platform tools do you mean?
Thanks for respnse btw
spartanier7 said:
I have not even installed sdk...
so should i download install and pull the aapt to the folder where apk-tool is in?
Which platform tools do you mean?
Thanks for respnse btw
Click to expand...
Click to collapse
After installing the sdk, run the updater and tick platform tools, and let that install. It will then put all necessary tools in a folder under the sdk. You don't need to put aapt in the same folder as apktool, just make sure it's in your path.
Sent from my Galaxy Nexus using xda premium
All right. Thanks for that. I will just try that and respond later whether it worked or not.
apktool had (has?) problems with ICS. dont even try. if thats where youre getting at spend your time searching xda and rootz for specific solutions, theres been workarounds and even bigfixes/updates. apktool is a ***** to get right because its error messages are basically gibberish, for instance i wasted half a day simply because aapt was not in the same directory (it was in PATH and i could access it, but stil..).
heres my apk environment, maybe it helps: http://www.mediafire.com/?2lyji92qqud6rym
I never had any issues with apktool and ics, and I have done numerous smali edits to both framework and nonframework files. As long as aapt is up to date, and framework-res from the rom you're editing is imported, everything works as expected.
molesarecoming said:
apktool had (has?) problems with ICS. dont even try. if thats where youre getting at spend your time searching xda and rootz for specific solutions, theres been workarounds and even bigfixes/updates. apktool is a ***** to get right because its error messages are basically gibberish, for instance i wasted half a day simply because aapt was not in the same directory (it was in PATH and i could access it, but stil..).
heres my apk environment, maybe it helps: http://www.mediafire.com/?2lyji92qqud6rym
Click to expand...
Click to collapse
Well, i have just downloaded and installed sdk+platform tools.
I´ve out apktool.jar into the platform tools folder and now it seems to work fine!
BIG THANKS for your help
If something goes wrong contrary to expectations I hope that I may come back to this thread and ask again.
Thanks my grandmasters
Edit:
Need help again..
As i said i want to change some headlines in the Settings. So i decompiled the Settings apk and changed the settings_headers.xml
I just changed one line that says
<header android:title="@string/eos_settings" />
Click to expand...
Click to collapse
to
<header android:title="@string/nexium_settings" />
Click to expand...
Click to collapse
now the console says that no ressource was found that matches @string/nexium_settings.
This may be obvious and I feel a bit ashamed for asking but what exactly do i have to change now to make it work?
Thanks in advance.
Sorry again for my noobish questions but.. it takes a village to raise a town
spartanier7 said:
Well, i have just downloaded and installed sdk+platform tools.
I´ve out apktool.jar into the platform tools folder and now it seems to work fine!
BIG THANKS for your help
If something goes wrong contrary to expectations I hope that I may come back to this thread and ask again.
Thanks my grandmasters
Edit:
Need help again..
As i said i want to change some headlines in the Settings. So i decompiled the Settings apk and changed the settings_headers.xml
I just changed one line that says
to
now the console says that no ressource was found that matches @string/nexium_settings.
This may be obvious and I feel a bit ashamed for asking but what exactly do i have to change now to make it work?
Thanks in advance.
Sorry again for my noobish questions but.. it takes a village to raise a town
Click to expand...
Click to collapse
You need to add your string to values/public.xml. Then it will compile.
Sent from my Galaxy Nexus using xda premium
All right. That error is gone now.
Instead I get another type of error message.
"my path"/Settings/res/values/public.xml:2600: error: Public symbol string/nexium declared here is not defined
Click to expand...
Click to collapse
So where do i have to define that string?
Edit:
Nevermind. I got it. Just had to change the values/strings
Ok.. now i have another kind of problem. Compiling the apk successed!
Problem is that though my changes the actual displayed hedlines have NOT changed..
Maybe someone can help me since i know that some of you must have it done at least once..
I´ll show up my steps and maybe someone can discern the mistake or what I forgot and help me to get it right
1. I changed the settings_headers.xml
I changed the line
header android:title="@string/eos_settings" />
Click to expand...
Click to collapse
to
header android:title="@string/nexium_settings" />
Click to expand...
Click to collapse
2. I changed values/public
I changed the line
<public type="string" name="eos_settings" id="0x7f0b0660" />
Click to expand...
Click to collapse
to
<public type="string" name="nexium_settings" id="0x7f0b0660" />
Click to expand...
Click to collapse
3. I changed values/strings
I changed the line
<string name="eos_settings">EOS Settings</string>
Click to expand...
Click to collapse
to
<string name="eos_settings">Nexium Settings</string>
Click to expand...
Click to collapse
4. recompiled
5. pulled the xml folder out of the new compiled apk and put it back in the original .apk
6. put the Settings.apk back to the ROM
I hope someone can help me since I don´t really know what else I have to change to get it working since all these changes have not changed the actual displayed Headlines in the settings
<string name="eos_settings">Nexium Settings</string>
needs to be:
Code:
<string name="nexium_settings">Nexium Settings</string>
Questions or Problems Should Not Be Posted in the Development Forum
Please Post in the Correct Forums & Read the Forum Rules
Thanks ✟
Moving to Q&A
Great! It worked as I wanted it.
But I am a 98% sure that I had made that change you mentioned before..
This time I copied not only the xml folder but also the file named "ressources" to the original "Settings.apk"
May that be the reason it worked now? Or should the xml folder be enough?
Again thanks for your help.
spartanier7 said:
Great! It worked as I wanted it.
But I am a 98% sure that I had made that change you mentioned before..
This time I copied not only the xml folder but also the file named "ressources" to the original "Settings.apk"
May that be the reason it worked now? Or should the xml folder be enough?
Again thanks for your help.
Click to expand...
Click to collapse
You need to copy over the resources file as well. It holds the /values/public.xml file among others.
Well,
here I go with another Question.
If i want to change the order of the headlines and their sub options.. Do I just have to change their order in the settings_header.apk?

Help work out bugs in CM9/10/sense4/aokp- smali/baksmali and more to come..

How can I contribute to development?
Post #1 is a tutorial for how to decompile/recompile jar files to help with the project.
Post #2 will have information on how to pull a proper logcat and how to post your logcat
___________________________________________________________________
I'll write up a quick little guide for smali/baksmali that can be used with the previous resource I posted.
First, windows will work just fine. You will have to install the java JDK(not sdk, you can have both however), this is straightforward, just google and follow directions.
Next, download http://smali.googlecode.com/files/smali-1.3.2.jar and http://smali.googlecode.com/files/baksmali-1.3.2.jar (both are also attached)
If you can already type "adb" in the command prompt of windows, then the path was set for the tool.. find where you have ADB at, and paste those files into the same directory. If not follow the directions in the following quote, except you will be putting the above downloaded files in the directory you chose.
There's two simple ways to get there:
1 way = click Start > Control Panel > System icon.
2nd way = click the Start button, right-click “My Computer”(Computer for Vista/7) and select “Properties”.
If your using XP, your there. If your using Vista/7, click on Advanced system settings on the left side.
You should now be in the System Properties window.
Click on the Advanced tab.
Click on the Evironment Variables... button
In the System variables(lower box), scroll through the list until you see Path under the Variable column.
Click on it to highlite it, click on the Edit... button.
We are going to add our path to adb, where we installed the SDK, in the Variable value: box.
Make sure your cursor is at the end of the last entry, and type this:
;C:\android\tools\
Click to expand...
Click to collapse
Press the windows button or click start button, type cmd and press enter(to open command prompt), and type "java -jar baksmali-1.3.2.jar -o out/rogers/dexout/rogers-classes.dex" and see if the error it gives you shows you that there is no "rogers-classes.dex" file, if so then you've done everything right thus far.
Now you should look at the resource I had posted before, so you don't have to search, here it is again http://rootzwiki.com/topic/19262-protip-getting-data-working-on-that-epic-port-you-just-did/
For this example, look under where it says "Data:", I am going to do what it says for the framework.jar file. Jar files are basically zip files, rename framework.jar to framework.zip, then unzip it with whatever program you use, making sure you know where it is located. Do this for BOTH the cm9 rom, and also with the stock rom(we should be able to use any rom we currently have, ARHD, energy, speedrom, etc). I would name the stock rom zip folder "base" and the cm9 zip folder "port", so you can keep track easily.
If you have followed along this far, you will have a file called classes.dex, this will be what we are decompiling for both cm9 and stock, then we will copy files as needed, and recompile just the cm9 classes.dex, so again, pay attention to which is which, and what the path is. Ignore the other file that was unzipped for now, just know when you rezip it, you have to replace the original classes.dex file and zip it up with the other file that it was unzipped with.
So lets say this is the result, I have a folder c:\android\porting\base folder that contains a classes.dex file, and a c:\android\porting\base(I renamed the unzipped folder after I unzipped each) that also contains a classes.dex file.
Here is a post that explains what we are about to do if you need a reference. http://forum.xda-developers.com/showpost.php?p=4152564&postcount=2
To decompile(if you correctly installed the java jdk and set the path correctly for baksmali/smali) you would type this in:
Code:
java -jar baksmali-1.3.2.jar -o out/base locationOFyour/classes.dex
the "out/base" is where it will put the output files, in a directory called OUT in your USER folder. Quick protip if you are unsure how to type in the location of the classes.dex file, just type in "java -jar baksmali-1.3.2.jar -o out/base" and then DRAG the classes.dex file from your file explorer to the command prompt window, and IT will put the correct path(it should be something like ~/android/porting/base if I remember correctly). I am working on OSX, so you may have to do this if the example isn't helpful enough. Protip #2: Write all this $h*t down! Create a text document with every step you do, then you can just copy/paste the line above, and modify it as needed- this also helps keep track of what you are doing- aka a changelog.
If you followed protip #2 above, copy the same command you just typed in, but change where it says "base" in the path, to "port". If you have two folders in your OUT folder, one called base, and one called port, you have done everything correctly thus far.
Since this is an example, this is what the resource I posted above on rootzwiki says to do with the result output files:
android/net - the ConnectivityManager classes and interfaces as well as all the NetworkStateTrackers.
android/telephony
com/android/internal/telephony
Click to expand...
Click to collapse
So basically I am just copying everything from the above folders from my BASE, to the PORT, overwriting each file in the port. Once done, you will type this:
Code:
java -Xmx512M -jar smali-1.3.2.jar out/port -o new-classes.dex
This is because we are recompiling the files in our PORT, and it will create a file in the root of your USER folder called new-classes.dex. Rename the file classes.dex, unzip the CM9 framework.jar and replace the original classes.dex, rezip it, then rename framework.zip to framework.jar.
This concludes the tutorial. Once you have everything setup, if you follow protip #2, the matter of baksmali/smali is a quick copy/paste into command prompt, so modifying a jar file will take less than 5 minutes. Push the resulting jar file into the appropriate folder on your phone, reboot your phone, run a logcat(I have a good guide linked in the BIBLE in my signature how to logcat like a pro), and see if data(for this example, you could be working on GPS or whatever) is working any better.
Protip #3: You've just learned quite a bit, the same can be done to most apk's- rename whatever.apk to whatever.zip, unzip it, then baksmali the resulting classes.dex file- this is how many programs are backported to older versions of android, hacked, etc. If you want to see the simple edit that was made to the ext.jar using this same process that got data working, you can see it here: http://forum.xda-developers.com/showpost.php?p=25786037&postcount=13
If anyone wants to try to push the file I just created and attached, feel free.. if you have major issues, create a logcat, if not, post your result. My changelog:
In android/net I copied over ConnectivityManager.smali and each file beginning with "NetworkState"
In android/telephony I copied over all the files
There was no com/android/internal/telephony directory, so it was skipped
Click to expand...
Click to collapse
This is all I have time for at the moment, I have to go to work soon so I cannot test the file.. this tutorial took a bit to do, so I am hoping someone at least gives it a try to make it worth my time. I can give some assistance, but would prefer that if it is something you can figure out on your own with some basic googling, please do so.
I will update on different methods to pull a proper logcat in the near future, for right now please post what rom you are on, and what you expect the log to contain such as "I was enabling data"..
Also reserved just in case
As posted in the previous thread, there are probably 250+ more constants in the base rom than there is the in the cm9 RILConstants.smali file. Are these the kinds of glaring differences we need to look for, or is this just the difference between sense/aosp...
I'm pushing your framework.jar and seeing how it works out. I'll get back to you in a moment.
Just boot loops...
Hey, just wanted to throw this out there. I found an amazing studio that makes digging around in apk and jar files incredibly easy to do.
You can check it out here - http://www.virtuousrom.com/p/ten-studio.html
I haven't tried any jar files with it but it says they are supported. Might be worth checking out.
Ok I just tried switching it our with your framework.jar and it got to upgrading the 82 apps now it's stuck in a bootloop after that
Sure wish we could get some if those Kats over here. The virtuous team always had something cool for the g2
Sent from my HTC_Amaze_4G using xda app-developers app
craigtut said:
Hey, just wanted to throw this out there. I found an amazing studio that makes digging around in apk and jar files incredibly easy to do.
You can check it out here - http://www.virtuousrom.com/p/ten-studio.html
I haven't tried any jar files with it but it says they are supported. Might be worth checking out.
Click to expand...
Click to collapse
Yep, I saw that and saved it to my read it later account.. but I never even boot into windows anymore, lol. If someone wants to try it out, if it streamlines things.. would definitely be pretty awesome. I didn't know it did jars, I thought it just did apks.
Learning how to do it still has its own value I think tho Thanks for sharing craig
bos2333 said:
Ok I just tried switching it our with your framework.jar and it got to upgrading the 82 apps now it's stuck in a bootloop after that
Click to expand...
Click to collapse
I noticed afterwards that I included a few too many files, I should have done just the one file rather than 3.. I think we will have much more success by making single changes, seeing if it improves things, or at LEAST continues to boot, rather than making broad sweeping changes.
Even if it gets stuck in a bootloop, see if it will post a logcat, the errors it puts out will help figure out what was too much.
Also, I think the mentioned guide would be MUCH more direct for porting sense4- as both have all proprietary htc files, and therefor the different flags in the smali file will help a ton.. as far as porting cm9, we will likely have to be much more concise about the changes- it likely won't take much, just a few changes here and there.
bos2333 said:
Ok I just tried switching it our with your framework.jar and it got to upgrading the 82 apps now it's stuck in a bootloop after that
Click to expand...
Click to collapse
Here's the logcat from replacing framework.jar with the one you supplied...I had to zip it though because it's too big apparently
Silentbtdeadly said:
Yep, I saw that and saved it to my read it later account.. but I never even boot into windows anymore, lol. If someone wants to try it out, if it streamlines things.. would definitely be pretty awesome. I didn't know it did jars, I thought it just did apks.
Learning how to do it still has its own value I think tho Thanks for sharing craig
Click to expand...
Click to collapse
i guess ill give it a go
ill mess with it too once i get my straight talk plan. (cause right now i dont have a plan so i cant check data )
you can use Winrar to extract .jar files so you don`t have to rename to .zip http://www.rarlab.com/download.htm download it here
Ok, so again, very new to this...I just merged the 4 MobileDataStateTracker files from Android/net from speedrom 5.1 to the cm9...same thing, boot loops.
bos2333 said:
Ok, so again, very new to this...I just merged the 4 MobileDataStateTracker files from Android/net from speedrom 5.1 to the cm9...same thing, boot loops.
Click to expand...
Click to collapse
Then you likely have the cause of the original boot loop. Two things you can do, check the logcat - it may tell you something useful.. another thing to do is get software to compare the files, I think for windows there's a free one called winmerge... The output files are usually text, and you may see some specific lines that would help us from the stock file and change those(things relating to data), leaving everything else alone.
Someone recently posted how to do a log for data errors, but I have a really good tutorial in the bible in my signature, logcat like a pro.
Sent from my HTC_Amaze_4G using xda app-developers app
i'm trying to learn my ways around the android ecosystem... please correct me if I have any incorrect info below
bascially, what you're doing for this tutorial is trying to decompile and debug problems, only going up to the assembly level (smali)
jar/apk = container like a zip... contains resources like compiled binaries and images etc
dex = compiled binary for the android system
you first disassemble the dex files to smali ("assembly") files
-> a developer here would make changes to the smali... lets say you don't make any
you reassemble back to dex, gather it into a jar/apk file to put on the phone
-------------
for porting a phone to use CM9/10/aokp, you basically use the base CM9/10/aokp system, copy over relevant jar/apk, and debug to fix any problems (like function calls, data etc)?
using logcat, you can see where function calls fail (or when you have a exception), and then try to fix it?
how good is debugging? basically you can see most of the source code?
would it be also possible to go dex->smali->java? like this post, though it says its not ideal either http://stackoverflow.com/questions/5582824/decompile-smali-files-on-an-apk
Silentbtdeadly said:
Then you likely have the cause of the original boot loop. Two things you can do, check the logcat - it may tell you something useful.. another thing to do is get software to compare the files, I think for windows there's a free one called winmerge... The output files are usually text, and you may see some specific lines that would help us from the stock file and change those(things relating to data), leaving everything else alone.
Someone recently posted how to do a log for data errors, but I have a really good tutorial in the bible in my signature, logcat like a pro.
Sent from my HTC_Amaze_4G using xda app-developers app
Click to expand...
Click to collapse
Yeah, I attached a logcat last page and looked at it, saw the errors. I'll do some searching tomorrow to see if I can work my way through some of them.
Sent from my HTC Ruby using xda app-developers app
paperWastage said:
i'm trying to learn my ways around the android ecosystem... please correct me if I have any incorrect info below
bascially, what you're doing for this tutorial is trying to decompile and debug problems, only going up to the assembly level (smali)
jar/apk = container like a zip... contains resources like compiled binaries and images etc
dex = compiled binary for the android system
you first disassemble the dex files to smali ("assembly") files
-> a developer here would make changes to the smali... lets say you don't make any
you reassemble back to dex, gather it into a jar/apk file to put on the phone
-------------
for porting a phone to use CM9/10/aokp, you basically use the base CM9/10/aokp system, copy over relevant jar/apk, and debug to fix any problems (like function calls, data etc)?
using logcat, you can see where function calls fail (or when you have a exception), and then try to fix it?
________________________________________________________________________________________________
how good is debugging? basically you can see most of the source code?
would it be also possible to go dex->smali->java? like this post, though it says its not ideal either http://stackoverflow.com/questions/5582824/decompile-smali-files-on-an-apk
Click to expand...
Click to collapse
Everything above the line=yes(ish). That is a fair explanation of things. If you mean how good is the debugging on smali'd files.. you should do it to some and find out
I'm not sure I understand what you mean by dex>smali>java.. dex is the compiled, smali is decompiled, it can't be more decompiled than smali to the best I can see. What that link you posted was talking about was different tools to get the job done- some can be helpful, tho many don't work properly with ICS as of yet.
Sorry if my answers are unclear, I wasn't sure of the questions perhaps..
So there are some smali edits in this miui4 porting guide that can be looked at to help understand how/what files matter.. furthermore, all ril specific edits could be looked at for our phone http://forum.xda-developers.com/showpost.php?p=28885450&postcount=2
Also, the third post has some great info on debugging and reading logs.. http://forum.xda-developers.com/showpost.php?p=28885450&postcount=3
That entire guide is extremely comprehesive, and the language isn't more complex than what you are already doing, so you will learn quite a bit. I may pull relevant info from that guide to the second post when I have more time.
Silentbtdeadly said:
Everything above the line=yes(ish). That is a fair explanation of things. If you mean how good is the debugging on smali'd files.. you should do it to some and find out
I'm not sure I understand what you mean by dex>smali>java.. dex is the compiled, smali is decompiled, it can't be more decompiled than smali to the best I can see. What that link you posted was talking about was different tools to get the job done- some can be helpful, tho many don't work properly with ICS as of yet.
Sorry if my answers are unclear, I wasn't sure of the questions perhaps..
Click to expand...
Click to collapse
my question is whether we decompile all the way back to the Java source instead of stopping at the assembly(smali) stage
from doing more searching, it looks like you might be able to get readable Java source code, but you can't recompile them as it'll be incomplete and as you said might not work on ics
I assume one would need to to flash the cm9/10 and then get those logcats
Silentbtdeadly said:
Then you likely have the cause of the original boot loop. Two things you can do, check the logcat - it may tell you something useful.. another thing to do is get software to compare the files, I think for windows there's a free one called winmerge... The output files are usually text, and you may see some specific lines that would help us from the stock file and change those(things relating to data), leaving everything else alone.
Someone recently posted how to do a log for data errors, but I have a really good tutorial in the bible in my signature, logcat like a pro.
Sent from my HTC_Amaze_4G using xda app-developers app
Click to expand...
Click to collapse
Ok, so I tried again this morning by only adding "HtcMobileDataStateReceiver.smali" to the port in the android/net, and I got the boot loops again. Checked the logcat and found this...
I/ServiceManager( 144): service 'media.audio_flinger' died
I/ServiceManager( 144): service 'media.camera' died
I/ServiceManager( 144): service 'media.player' died
I/ServiceManager( 144): service 'media.audio_policy' died
I/Netd ( 496): Netd 1.0 starting
D/AndroidRuntime( 497):
D/AndroidRuntime( 497): >>>>>> AndroidRuntime START com.android.internal.os.ZygoteInit <<<<<<
D/AndroidRuntime( 497): CheckJNI is OFF
I/dalvikvm( 497): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory
D/dalvikvm( 497): Unable to process classpath element '/system/framework/framework.jar'
I/ ( 498): ServiceManager: 0x1293958
E/JNIHelp ( 497): Native registration unable to find class 'android/debug/JNITest', aborting
Any ideas? It seems like it's not taking my new classes.dex file for some reason.

Categories

Resources