I downloaded the PDroid source from the XNA forum and fount 3 files in it with the .patch extension. Could somebody please explain me what are files with this extension for? Ignore the fact that they are from the PDroid source since I think there are other projects using them. As I can see these files can be opened in text editor and there are some script lines in them but I don't know what they are for?


3 Answers 3


Patch files are not specifically to do with Android. They just represent a difference between two text files (or two folders of text files). They can be produced by the diff tool, or by a version control system, and the same change can be applied to files by the patch tool, or by a version control system.

Patch files are often used by programmers to communicate a change that should be applied to source code.

  • Thank you for your explanation. So these are in essence files of differences between older and newer version of source code. For example I download a source from git repository and then run the patch tool on those folders with patch file as "argument" as I understood it? Why not just do a sync to pull changes from the central repository? Feb 13, 2014 at 13:46
  • In this case: because it's not possible that way. It would mean to do that for each and every ROM existing. PDroid install involves patching parts of the ROM installed on the target device, see their install instructions (and the answer by RossC).
    – Izzy
    Feb 13, 2014 at 14:00

From the XDA thread for PDroid these are if you are building PDroid from source.

EDIT: The specifics of what a .patch file is are in Dan's post.

If you are building the source you need to take the following steps:

Download: PDroid 2.3.4 source (v1.27) (yes it is based on 2.3.4 but also works with 2.3.3 and 2.3.5 flawlessly)

Get the 2.3.4 source from AOSP (branch: android-2.3.4_r1)

Extract the patches from the above archive to the 2.3.4 tree root



patch -p1 -i build.patch
patch -p1 -i frameworks.patch
patch -p1 -i libcore.patch

Building from source:

Make a clean build

Apply the patches (see above)



source build/envsetup.sh
make update-api
mmm frameworks/base
mmm frameworks/base/services/java
mmm libcore
  • 1
    Thank you for detailed example. Core of the question was not really about PDroid but about the format itself but these examples that you wrote are quite helpful in understanding. So those files are nothing more then the differences between original android AOSP source and changed files that author of PDroid used to build his app? So instead of downloading new 9GB repository one can just run the patch on existing one and get the changes that author made? Feb 13, 2014 at 13:53
  • Exactly that. So the download gets lot smaller. That's also one of the reasons .patch files are used in general: saving bandwidth and storage. And for devs, making it easier to see what exactly was changed, and how.
    – Izzy
    Feb 13, 2014 at 14:02
  • Yeah that's why I mentioned Dan's answer in mine, no point in replicating it. You now have the 'what' and the 'how'!
    – RossC
    Feb 13, 2014 at 14:36

Using git am:

go to the repository directory and execute the command:

git am <path-to-file.patch>

It will find the correct file in the repository directory and execute the changes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .