Wednesday, 3 December 2014

How to move user apps to system partition

The installed apps in your phone is categorize as system app and user app. The user apps are normal apps which user install through google play store. System apps are apps which comes pre-installed in the system partition when you buy the new phone.
for example : gmail app

Today I'm gonna tell you how to move user apps to system partition.

Requirements :
1. Rooted android phone.
2. ADB shell.

Prerequisites  :
1. Open you terminal ctrl+alt+t and check adb devices. It should be connected.
How to connect :
1. In Windows : Install drivers of your phone.
2. In linux : make 51-android.rules file and add vendor ID of you phone there.
for complete instructions go here .


ADB METHOD


case 1 : Moving user app to system app.


step 1 : Open adb shell in terminal.
               adb shell
step 2 : Get superuser permission.
               su
step 3 : Change directory to /data/app.
               cd /data/app
step 4 : Remount system partition of your device, with read write permission.
               mount -o remount,rw /system
step 5 : Copy the .apk from data to system directory.
               cp app_name.apk /system/app
step 6 : Remove the .apk from /data/app directory.
               rm app_name.apk
step 7 : Now change .apk permission to 644.
               chmod 644 /system/app/app_name.apk
step 8 : exit --> adb reboot.
               exit
               adb reboot.


and, you are done !!


case 2 : When .apk is in your computer.


step 1 : Change directory to top of your .apk
               cd folder_name
step 2 : Push .apk to sdcard
               adb push app_name.apk /sdcard/
step 3 : Open adb shell
               adb shell
step 4 : Remount system partition of your device, with read write permission.
               mount -o remount,rw /system
step 5 : Copy the .apk from data to system directory.
               cp /sdcard/app_name.apk  /system/app
step 6 : Now change .apk permission to 644.
               chmod 644 /system/app/app_name.apk
step 9 : exit --> adb reboot.
               exit
               adb reboot.
  
and you are done !! 


Saturday, 4 October 2014

                                               Install ADB package in ubuntu


1. open terminal by pressing "ctrl + alt + T",now you have the window like this



2. Add the  repository by this address:
 
   $ sudo add-apt-repository ppa:nilarimogard/webupd8






3. You need to update again By the Command

   $ sudo apt-get update



4. Now you are ready to install ADB package in ubuntu

  $ sudo apt-get install android-tools-adb android-tools-fastboot




Tuesday, 18 March 2014

Decompiling Android | How to get source code from an .apk file.

DISCLAIMER: This tutorial is only for emergency and evaluation purposes. Do not use it for extracting source code of a proprietary application.


Ok, so have you ever been in a condition when you don't have the source code of your application, your whole pc has crashed, your backup hard disk just exploded last night unexpectedly, your pen drive has been just ran over by a full loaded truck and your cloud service provider's server caught fire, you lost your github account info and you have lost all your source and your hope and now your left with only your apk file uploaded to a store. You might think of writing your whole application from the scratch but what if it is a really heavy application with huge blocks of code and numerous java and xml files.


Then, then, then, what would happen?


You don't need to get depressed as we are going to show you how you can extract source code, i.e. Java and XML files from a .apk file. Its not a kind of magic, its just reverse engineering!

Note: We do not take credit of any software used in this tutorial. All these softwares are created by some other people and all credit goes to them.

First and foremost, the prerequisites for this tutorial are:



  1. A Windows (either XP, Vista, 7 or 8, any edition and either 32-bit or 64-bit will do). We will try to release a Linux or Mac version ASAP.
  2. dex2jar from Google.
  3. Java Decompiler : Go here and download JD-GUI.
  4. apktool-version.tar.bz2 and apktool-install-windows-something-.tar.bz2. For extraction use any compression utility e.g. WinZip, WinRAR, 7Zip, etc.
  5. framework-res.apk file.


Now, lets turn on your Windows pc and start:

Step 1: First create a folder sourcecode wherever you want to in your computer and put the downloaded apk file inside of that folder and rename the apk file to app.apk, its not necessary but for simplicity.


Creating "sourcecode" folder and renaming apk to "app.apk".


Step 2: Now rename the app.apk file to app.zip.



At this stage, if you are unable to see the extension of the app.zip after renaming it then press Alt+T+O. Then in the View tab, untick “Hide file extension for common files” and now you should be able to see the .zip extension of the app.zip file.



In Windows 8 and above, you only need to press Alt + H + double-click V to view hidden file extensions.

Step 3: Extracting the zip file. Right-click on app.zip and click on “Extract All...” option and extract the zip file.




In that folder you will be able to see drawable folders, etc. but you cannot directly see .java and .xml files right now.

Step 4: Now copy downloaded dex2jar.zip file into the sourcecode folder and extract it there.





Next, copy the classes.dex file from the extracted folder of the app.zip and put it in the extracted folder of the dex2jar.zip file.




Step 5: Getting .jar file from .dex file.

Now we need to open a command prompt and navigate to this folder. Or easily you can hold the Shift key and right-click on the dex2jar folder and select “Open command window here...”.



Type in the following command :

D:\sourcecode\dex2jar>d2j-dex2jar classes.dex



This will give you the classes-dex2jar.jar file containing the .java files.

Step 6: Getting .java files.

The above step will create the .jar file named as classes-dex2jar.jar which is the jar file of the package containing the sources i.e. .java files. For extracting .java files from .jar file open the downloaded file jd-gui.exe.Select “Open file...” and browse to the generated classes-d2j-dex2jar.jar file. Then select “Save All Sources...” or simply press Ctrl + Alt + S and save the sources in the sourcecode folder with filename src.zip. This will save the .java files as a .zip file.




Now, you have the .java files and the only thing you need now is .xml files.

Step 7: Extracting .xml files.

Now create another folder name “layout” inside the sourcecode folder and put all these inside these:

  • app.apk file
  • extracted files of apktool-v1.x
  • extracted files of apktool install window
  • framework-res.apk file



Open a command windows in this directory as specified in Step 5. Type in the following command:

D:\sourcecode\layout>apktool if framework-res.apk

D:\sourcecode\layout>apktool d app.apk




After the command has completed succesfully you will have folder inside “layout” which contains the .xml files.

Copy all the generated files and folders, i.e. src folder containing .java files and layout containing .xml files in a single folder and open it up either in Eclipse or Android Studio or whatever IDE you work in but you might face some errors that we will soon update on how to remove those errors, until then have fun.

And voila, now you have a complete android package source.

UPDATE: We lately noticed that we have originally downloaded the Linux version of apktool but later on that is rectified.

Thank You and please share if we helped you.