[Completed] [Q] APK rebuild and install issues - XDA Assist

I am learning how to mod Android apps.
I have rooted ASUS Transformer Prime for my experiments. It has busybox installed.
I have downloaded one of the games from /data/app directory, by copying it to sdcard and then using adb pull.
Then I have used apktool to disassemble apk and without any changes assembling it back. I did verify with Beyound Compare tool that resulting apk logically is same to original. All files inside are byte to byte same.
I ran zipalign on it.
Then I pushed it back to my device via adb push to sdcard and then copy it to /dev/app folder. restored permissions and owner.
When I tried to run the app I got the error, "Unfortunately application stopped".
The only difference between original and disassembled apk that I can see is that files inside the apk (which is zip) are in different order.
Can anyone shed the light on this problem? Does Android somehow remembered offsets of different files in that apk? Is there any log somewhere?
Thank you very much.

vasiliy_gagin said:
I am learning how to mod Android apps.
I have rooted ASUS Transformer Prime for my experiments. It has busybox installed.
I have downloaded one of the games from /data/app directory, by copying it to sdcard and then using adb pull.
Then I have used apktool to disassemble apk and without any changes assembling it back. I did verify with Beyound Compare tool that resulting apk logically is same to original. All files inside are byte to byte same.
I ran zipalign on it.
Then I pushed it back to my device via adb push to sdcard and then copy it to /dev/app folder. restored permissions and owner.
When I tried to run the app I got the error, "Unfortunately application stopped".
The only difference between original and disassembled apk that I can see is that files inside the apk (which is zip) are in different order.
Can anyone shed the light on this problem? Does Android somehow remembered offsets of different files in that apk? Is there any log somewhere?
Thank you very much.
Click to expand...
Click to collapse
Learned to use adb logcat.
Apparently app was failing because dalvik detected that timestamp on a dex file is different and decided that it should replace cached file in /data/dalvik-cache.
But that file is not writable for a group. Not sure why.

Related

Changing Market App Icons

Hello,
I did some searching before posting this and have come up with little results that are working for me. I have been able to change my stock icon apps using the method on androidcentral (sorry, can not post links yet). However, trying the same thing with Free Market Apps, I have been unsuccessful.
I am able to get the com.*.*.apk file off of my phone, and can extract the res folder, but after editing and pushing the file back onto the phone, the application is "uninstalled." I believe that I have to sign the apk file again, which I've tried doing with no success.
What I do not understand, is the app Bettercut has the ability to change these Market App Icons, so I thought we should be able to do so as well. If anyone has any knowledge of how to do this, I would greatly appreciate it.
Thanks
Hey you
Change your graphics. Uninstall the app from your phone, put the edited .apk on your sd card and install it with astro (or another app that installs apk files). If you update from market you'll lose customizations.
Hiya.
Yeah, I tried that, but I keep getting unable to install. I do have non-market apps checked, but still no luck. I'm basically just editing the graphic from the com.*.*.apk file, opeing the com.*.*.apk file with 7zip, placing the new graphic in the res/drawable folder, closing 7zip, then I put the com.*.*.apk file onto my SD card (after uninstalling original app) then use astro to install. Doing this is not working. I thought I might have to sign the apk file, rename it or something. Not really sure at this point.
ccapasso said:
Hiya.
Yeah, I tried that, but I keep getting unable to install. I do have non-market apps checked, but still no luck. I'm basically just editing the graphic from the com.*.*.apk file, opeing the com.*.*.apk file with 7zip, placing the new graphic in the res/drawable folder, closing 7zip, then I put the com.*.*.apk file onto my SD card (after uninstalling original app) then use astro to install. Doing this is not working. I thought I might have to sign the apk file, rename it or something. Not really sure at this point.
Click to expand...
Click to collapse
I got it to work by pushing the .apks back through adb and not using a File Manager. I changed a bunch of my Market icons without any problem. No fc's or install failures.
So say for example you were to change the Market Icon for Spare Parts. I assume you did the following:
Pulled com.androidapps.spare_parts.apk from /data/app
Edited the app_icon.png file within the res/drawable folder
Uninstalled Spare Parts
Pushed com.androidapps.spare_parts.apk back to /data/app
Or did you do it differently?
Thanks again for all the help on this. Not sure exactly what is going wrong on my end.
I never uninstalled the apk. I just drug a copy of the .apk to my computer, edited the image, and then pushed it back over the original one. Im in no way any kind of expert, but it worked when I did it.
Hmm. So are you going into /data/app and pulling the com.androidapps.spare_parts.apk (for example), editing, then pushing back w/ out signing or anything? I assume you are pushing back the same file, name exactly the same and everything.
So for example you would have pulled com.androidapps.spare_parts.apk from /data/app, edited the png within the apk file, then pushed com.androidapps.spare_parts.apk back to /data/app and it worked?
No rebooting, signing or anything?
I'm using Fresh 1.1 with MCK and again, do not have SD card partitioned for apps2sd yet.
Thanks again.
Yep, that's what I did. No updating, signing, nothin. I did reboot after I was all done. And I dont mess around with that apps2sd business either. So it should be the same.
gomorrah said:
I never uninstalled the apk. I just drug a copy of the .apk to my computer, edited the image, and then pushed it back over the original one. Im in no way any kind of expert, but it worked when I did it.
Click to expand...
Click to collapse
Wow that worked pretty nicely! I was trying to change the little slide bar that moves as you change screens. I kept upzipping the file and modifying it, then rezipping and trying to reinstall. 7zip lets you modify the .apk with out opening it up...glad this subject came up and you answered this!
Ok. Step by step here is what I did just now:
1. adb pull /data/app/com.androidapps.spare_parts.apk C:\Users\Chris\Desktop
2. Used 7zip to open the apk file.
3. Moved my app_icon.png file into the res/drawable folder and overwrote the current one
4. adb push C:\Users\Chris\Desktop\com.androidapps.spare_parts.apk /data/app/
5. adb shell
6. reboot
Doing this did not work. It only made the icon on my home screen for Spare Parts go away, and the app is no longer listed as being installed. I can still see the file in my /data/app/ directory, but it is not installed or showing up anywhere.
Any ideas?
ccapasso said:
Ok. Step by step here is what I did just now:
1. adb pull /data/app/com.androidapps.spare_parts.apk C:\Users\Chris\Desktop
2. Used 7zip to open the apk file.
3. Moved my app_icon.png file into the res/drawable folder and overwrote the current one
4. adb push C:\Users\Chris\Desktop\com.androidapps.spare_parts.apk /data/app/
5. adb shell
6. reboot
Doing this did not work. It only made the icon on my home screen for Spare Parts go away, and the app is no longer listed as being installed. I can still see the file in my /data/app/ directory, but it is not installed or showing up anywhere.
Any ideas?
Click to expand...
Click to collapse
Try pulling the original icon and editing it. Just make it a solid black square. Then put it back in and push to the phone. Sounds like your new icon changes the filesize enough that it needs resigned.

Help signing Apk?

I had a mod done to my widgetlocker apk , but i cant adb push it. Can someone please sign it for me so i can install using root explorer? Im not sure how difficult it is , so if its insanely hard or something im sorry for asking haha . Thanks .
Get apkmanager and it will sign it for you. Plus apk manager will let you decompile and recompile then sign so you can mod anything and it's a whole lot easier.
Sent from my Incognito Droid using Tapatalk
1. Add your JDK Directory to the Path variable (Right click on My Computer, Properties, Advanced, Environment Variables)
2. At the command prompt, navigate to the containing folder
3. keytool -genkeypair
4. jarsigner -verbose APPNAME.apk mykey
5. Push the signed app
sorry guys but im not real sure what a JDK directory is or anything. I didnt do the mod myself. i made a donation and had it done by someone on here. Once they returned it to me via email they told me to adb push it.. but i do not have any exp doing that and was hoping someone could help me out... there would be a nicely themed widgetlocker.apk in it for you haha
Different problem, same answer.
I have been trying to install a custom framework res for a while now. I am on a Mac. I simply have been changing ext to zip, unzipping, making changes, rezipping, using mv command in terminal to change to apk, and pushing to phone. It hasn't even kind of worked. Could someone please help? Are there any steps I'm missing? Do I need to sign the framework res apk?
Please help
lucas.scott said:
I had a mod done to my widgetlocker apk , but i cant adb push it. Can someone please sign it for me so i can install using root explorer? Im not sure how difficult it is , so if its insanely hard or something im sorry for asking haha . Thanks .
Click to expand...
Click to collapse
Post it or post a link to it and I'll sign it.
That said, if you modify one apk it is highly unlikely you will not modify others (which is a good thing). Therefore, I would highly recommend getting acquainted with the proper tools.
First you will need to install the Android SDK on your computer. Here is the link:
http://developer.android.com/sdk/index.html Bear in mind that to use it you will also need to install the JDK (Java Developers Kit) on your computer but the links are in the instructions so it is very easy.
In addition to the SDK download 7zip if you do not already have it. It is a free archive utility that enables opening and editing the contents of archives without extracting them.
Lastly, if you just plan on editing images download Stericson's autosign tool so that once you finish changing images you can resign the apk which is necessary to install. However, if you want to delve a little deeper into apps I highly recommend Apk Manager. Not only does it include a signing tool but can also decompile apks so that you can do deeper editing.
dkdude36 said:
I have been trying to install a custom framework res for a while now. I am on a Mac. I simply have been changing ext to zip, unzipping, making changes, rezipping, using mv command in terminal to change to apk, and pushing to phone. It hasn't even kind of worked. Could someone please help? Are there any steps I'm missing? Do I need to sign the framework res apk?
Please help
Click to expand...
Click to collapse
The framework-res.apk does not need to be resigned. In fact, there are few, if any, reasons why any system app would need to be resigned. Therefore, that should not be your issue.
That said, in the steps you listed above I see several areas which could problems so, it would be beneficial if you provided more information. Here are my initial comments:
1)When you are rezipping the apk are you recompressing the folder created when you unzipped the apk OR, are you selecting the contents of the folder (e.g. AndroidManifest.xml, res folder, etc. ) and compressing them? It is important to do it the second way I described.
2)No need to bother with the mv command as you are using it. Once you've rezipped the apk (it will likely be named Archive.zip) you will need to rename it "framework-res.apk" at which point you should only need to push the apk back to the phone. The process would go like this:
a)put modified framework-res.apk into the tools folder (located in the SDK folder)
b)open up terminal.app
c)type "cd " (without the quotes) and drag the tools folder located in the sdk folder into the terminal terminal window, and press Enter
d)type "./adb remount" (without the quotes) and press Enter
e)type "./adb push framework-res.apk /system/framework/" (without the quotes) and press Enter
f)type "./adb reboot" (without the quotes) and press Enter. (The phone will reboot which is necessary to see your changes)
g)Marvel at your accomplishment
Obviously, you should make a nandroid backup of your phone first so that in case you mess anything up you can restore it as if nothing happened.
If you have any more questions simply post them and I'd be happy to answer them. I bought and rooted my EVO the day it first came out which was before there were any Mac tutorials and have since become fluent in adb due to lots of trial and error.
could you possibly help me with my widgetlocker apk? i have adb pushed ( finally learned how to do that on mac) and it still wont install . have contacted ultralynx (he did the mod) but im not getting a response...thank you .
lucas.scott said:
could you possibly help me with my widgetlocker apk? i have adb pushed ( finally learned how to do that on mac) and it still wont install . have contacted ultralynx (he did the mod) but im not getting a response...thank you .
Click to expand...
Click to collapse
Hmmm... If ultralynx did the mod for you it is probably already signed. I've seen some of his threads and he clearly knows what he is doing. And, signing is apk-modding-101.
Where did you ./adb push the widget locker to? /system/app/ or /data/app/? Adb push does not install the apk if you push to /data/app/
My recommendation would be to do the following:
1)Using root explorer, find and delete the widgetlocker.apk from wherever you adb pushed it on your phone. Exit out of Root Explorer.
2)Reboot phone
3)Confirm that you don't have any previously installed versions of WIdget Locker on your phone. From your home screen press the menu button and navigate to Settings-->Applications-->Manage Applications-->All and look for Widget Locker. If you find it select and uninstall it.
4)Assuming the modified widget locker.apk was signed you should not need to mess with adb. You certainly can but it is not necessary and I'd hate to confuse you with the commands. So... Instead, connect the EVO to your computer and mount as disk drive. Put the widget locker.apk you want to install on your sdcard. Personally, I would recommend creating a folder named Apps and putting it in there.
5)Unmount phone as disk drive and unplug phone from computer
6) Using any file manager (Root explorer is fine) navigate to the apk on your sdcard and select install.
If that doesn't work let me know
Found problem, need answer
okolowicz said:
The framework-res.apk does not need to be resigned. In fact, there are few, if any, reasons why any system app would need to be resigned. Therefore, that should not be your issue.
That said, in the steps you listed above I see several areas which could problems so, it would be beneficial if you provided more information. Here are my initial comments:
1)When you are rezipping the apk are you recompressing the folder created when you unzipped the apk OR, are you selecting the contents of the folder (e.g. AndroidManifest.xml, res folder, etc. ) and compressing them? It is important to do it the second way I described.
2)No need to bother with the mv command as you are using it. Once you've rezipped the apk (it will likely be named Archive.zip) you will need to rename it "framework-res.apk" at which point you should only need to push the apk back to the phone. The process would go like this:
a)put modified framework-res.apk into the tools folder (located in the SDK folder)
b)open up terminal.app
c)type "cd " (without the quotes) and drag the tools folder located in the sdk folder into the terminal terminal window, and press Enter
d)type "./adb remount" (without the quotes) and press Enter
e)type "./adb push framework-res.apk /system/framework/" (without the quotes) and press Enter
f)type "./adb reboot" (without the quotes) and press Enter. (The phone will reboot which is necessary to see your changes)
g)Marvel at your accomplishment
Obviously, you should make a nandroid backup of your phone first so that in case you mess anything up you can restore it as if nothing happened.
If you have any more questions simply post them and I'd be happy to answer them. I bought and rooted my EVO the day it first came out which was before there were any Mac tutorials and have since become fluent in adb due to lots of trial and error.
Click to expand...
Click to collapse
Thanks for the help okolwoiz. I am fluent in adb and have been hacking for a while. I think I know the problem. The mod I was trying to theme (drop down notifications bar) is a .9.png, which means it is automatically resized to fit the phone. These are different than normal .png files. I know i need to use a draw9 something file in the sdk, but I don't know how. Any help would be great. Thanks
Dk
yeah i have tried all of that . It always just says "Application not installed" . No matter how i get it on the phone . ore than happy to send it to you to see if its the file or my phone .
Thanks this thread has helped me and I was just wondering through aimlessly.. And stumbled upon tis thread.
Sent from my netarchy_toast, froyo beast of a machine evo!
glad it helped someone haha

[Q] Can't delete Mms.odex, "No such file or directory"

I'm trying to use my new Sensation with the SIM from my Japanese iPhone, which requires replacing the stock Mms.apk with one that works with Softbank. That much I managed to do. Now when I try to open the Messaging app it crashes immediately, which is apparently normal and means I need to delete the old Mms.odex. But when I try, the command prompt window tells me:
rm failed for /system/app/Mms.odex, No such file or directory
I've made sure the folder isn't read-only (I managed to copy the new Mms.apk to it after all). Not sure what else could be going wrong. Thanks in advance for any help.
Its not a good idea to push files into the system directory of an odexed ROM like that. You usually need to push the appropriate .odex file with the .apk file.
Also could be a permissions problem. You need to make sure the permissions for the new file the are same as what's already in the directory.
Sent from my Sensation using Cyanogenmod
dr.m0x said:
Its not a good idea to push files into the system directory of an odexed ROM like that. You usually need to push the appropriate .odex file with the .apk file.
Click to expand...
Click to collapse
I know it's not ideal, but this method seems to work just fine; I've read a bunch of Japanese blogs that explain this is how to get MMS working with Softbank, and people on forums elsewhere say it's worked for them.
dr.m0x said:
Also could be a permissions problem. You need to make sure the permissions for the new file the are same as what's already in the directory.
Click to expand...
Click to collapse
How do I do that? I'm pretty new to all this, two days ago I was Googling where to find my Sensation's settings menu
If you want to ensure the mms.apk has correct permissions you can simply run:
adb shell chmod 644 /system/app/mms.apk
This will set the correct permissions for apps in the /system/app folder, although its worth reading up on linux permissions to understand what the command is actually doing.
Permissions didn't help, but I've managed to track down another Mms.apk file that works well enough - messages don't integrate properly with HTC's Messaging app, but I can send and receive MMS. I'm going to keep looking for a better apk but at least this one functions!

[Q] HELP - no build.prop

I just applied Daoist's CWM stock ROM update (should still be rooted, right?). It came up first time.
Then, I modded my build prop (set dpi to 120 because I like it that way). But maybe I screwed up the file name in Root explorer, because now I'm in a boot loop and if I try ADB PULL /system/build.prop it says "file not found."
I can't get SU through adb, so can't push build.prop to /system. ADB remount returns an error. permission denied. Transformer won't boot, so I can't do anything from it.
I CAN get to cwm, and have been trying to create an update.zip that will just copy build.prop to /system, but everything I have tried quits with "install aborted" message.
What can I do?
restore a nand and dont try and **** with it again, lol. no but really, restore a nand and then copy your build. prop and make a flashable zip and place on your sd card in case it happens again, so you can just flash it in cwm.
Resolved..
Well, why go back when you can go forward?
I went ahead and installed the Prime ROM. Looks like it is eating all my currently installed apps.
Y'all should know, though, that if your system can't find a build.prop it won't start. You can ADB to it and have a rudimentary set of commands, but your ability to significantly alter anything in your file system will be prohibited.
Lesson learned.
glg
as a side note most editors in android rename system files when you change them to "nameoffileyouedited".bak so if you pull and rename that file that might have fixed your problem. also try lcd dencity changer from the market. its a little less hazordous
mrevankyle said:
as a side note most editors in android rename system files when you change them to "nameoffileyouedited".bak so if you pull and rename that file that might have fixed your problem. also try lcd dencity changer from the market. its a little less hazordous
Click to expand...
Click to collapse
That is true. I had backups. But without a build.prop, the virtual machine won't start. There is no way to do a file operation to replace the backup. At least none that I found. I had to flash the whole system.
glg

Replacing file in app data folder with binary identical file (same file) caused problem (protection/security?) - Solved

Scenario:
Fresh restore app from backup
Start app - if i don't touch anything app start normally
Fresh restored app from backup
Copy file from /data/data/XXX/files/my_file somewhere out (other directory)
Copy the same file back (overwrite original, files are binary same, same hash, just copy it back...)
App start with errors!
I checked permissions same as before... Compare files, hash, same as at the beginning ...
What is it? some "tamper" protection, security?
Redmi Note 9 Pro, Android 10, Security patch level 2021-04-01, MUI 12.0.5 Stable, Rooted, Magisk
Copying is not a good idea, because the application probably has its odex file. If you changed something in the apk file, the crash is obvious.
It's not APK file, its database (sqlite) ...
and i don't change anything, just copy file out, same file without changes copy back (overwrite original)
First i think about some CRC checks.. but problem persist if i copy the same file (same timestamp, same permission, same CRC)
Application somehow knows that i touch that file. But app it's not running, no child processes..
Sorry, I didn't pay attention that it didn't apply to apk. A database can be used by a service, not necessarily an application.
Try doing the same thing in TWRP.
So the correct answer to this problem was "SE Context" (SELinux)

Categories

Resources