Android emulator patch for configurable IMEI, IMSI and SIM card serial number
My post about hacking the emulator's IMEI number gained a lot of interest, hence I've decided to prepare a patch which makes IMEI, IMSI and SIM card serial configurable on a per-AVD basis. It's necessary to recompile the emulator with the patch applied, so setup your build environment as a first step. I suggest using Ubuntu 10.10 and following the Android compilation hints.
Patching the emulator
The next step is to fetch the Android source code tree as described on the Getting the Source page and apply the emulator patch (most likely you'd want to use froyo branch, but the patch should work with the master branch too):
czajnik@czajnik:~/froyo$ patch -p1 -d external/qemu/ < froyo_qemu_imei_patch_20101119.diff patching file android/avd/hardware-properties.ini patching file android/avd/hw-config-defs.h patching file android/avd/info.c patching file android/utils/ini.c patching file android/utils/ini.h patching file telephony/android_modem.c patching file telephony/sim_card.c
Now we can rebuild the patched emulator for Linux:
czajnik@czajnik:~/froyo$ make emulator
When the compilation completes, copy the emulator binary into your SDK tools directory (I have SDK installed under /opt/android-sdk-linux_x86/), replacing existing file (you may want to backup it first):
czajnik@czajnik:~/froyo$ cp out/host/linux-x86/bin/emulator /opt/android-sdk-linux_x86/tools/
You may also want to compile the emulator for Windows:
czajnik@czajnik:~/froyo$ USE_MINGW=1 make emulator
When the build completes, look for out/host/windows-x86/bin/emulator.exe. Copy it to the tools directory, replacing existing emulator.exe.
How to use
Now you can customize IMEI, IMSI and SIM serial number by editing the AVD's config.ini file. The following new properties can now be used:
hw.gsmModem.imei- string of up to 15 digitshw.gsmModem.imsi- string of up to 15 digitshw.gsmModem.simSerial- string of up to 20 digits
Here's a sample file:
czajnik@czajnik:~$ more ~/.android/avd/A15i.avd/config.ini skin.name=QVGA-L image.sysdir.1=platforms/android-3/images/ skin.path=platforms/android-3/skins/QVGA-L hw.gsmModem.imei=123451234512345 hw.gsmModem.imsi=543215432154321 hw.gsmModem.simSerial=11223344556677889900
Testing
To test the new settings you can build and run this sample application (see the screenshot below). Enjoy!
Update (Jan 22nd, 2011): I've received complaints about the patch failing to apply properly with the newer versions of the Android emulator (indeed, the emulator seems to be a moving target). Find the updated versions of the patch below:
- android_imei_patch_tools_r8_20110122.diff - version for the
tools_r8branch (verified with revision3fd4433273472624235d7f4df342d3c0ce41bd4f) - android_imei_patch_tools_r9_20110122.diff - version for the
tools_r9branch (verified with revision3bf6efc0928555529c3df28d291117390b840c16) - android_imei_patch_master_20110122.diff - version for the master branch (verified with revision
b2d3df36e6e0d22c00fcddb51f9b0f4f754bfda4)
The commit signatures refer to external/qemu project, of course.
Update (Jan 23rd, 2011): One more update of the patch, for the Donut release:
- donut_imei_patch_20110123.diff (verified with revision
b95f8924a76897bd0f983a9be07dc618d8b0e3d3)
Update (June 1st, 2012): Upon request, here's a version for ICS:
- android_imei_patch_4_0_4 (verified with revision
7c36dab6d61ab61b2a2f8034938fc686c68d4960)
Remember, that you need to build emulator-arm and emulator-x86 targets!









January 8th, 2011 - 16:17
You are attempting to build on a 32-bit system.
build/core/main.mk:78: Only 64-bit build environments are supported beyond froyo/2.2.
please tell me this is not true!!!!!!
January 9th, 2011 - 17:17
I’m afraid it is true
, take a look at this thread. Personally I don’t agree with the technical reasons outlined there, I believe that it was just an arbitrary decision made by Google to unify the build environment internally.
Search the mailing list archives, there are some patches available if you want to build on 32-bit system!
January 22nd, 2011 - 08:12
patching file android/avd/hardware-properties.ini
Hunk #1 FAILED at 150.
1 out of 1 hunk FAILED — saving rejects to file android/avd/hardware-properties.ini.rej
patching file android/avd/hw-config-defs.h
Hunk #1 succeeded at 143 with fuzz 2 (offset -7 lines).
patching file android/avd/info.c
Hunk #1 succeeded at 253 (offset -6 lines).
Hunk #2 succeeded at 316 (offset -6 lines).
Hunk #3 succeeded at 951 (offset -6 lines).
Hunk #4 succeeded at 1054 (offset -6 lines).
patching file android/utils/ini.c
patching file android/utils/ini.h
Hunk #1 succeeded at 89 (offset 30 lines).
Hunk #2 succeeded at 104 (offset 30 lines).
patching file telephony/android_modem.c
patching file telephony/sim_card.c
could you give me an idea of the problem. I followed, everything you have suggested
January 22nd, 2011 - 20:48
Take a look at the post again – I’ve updated the patch for the new Android releases.
January 22nd, 2011 - 22:42
http://blog.codepainters.com/2010/10/27/compiling-android-sdk-on-ubuntu-10-10-maverick-meerkat/
I followed the intructions for ubuntu 10.10 right down to a Tee.
I am unsure which version your commands get but that is what I did, could you suggest a mod. Cause I am kind of desperate.
January 22nd, 2011 - 23:57
Well, I can just suggest you try the new patches I uploaded today. It is the patching step that fails for you, and not the compilation, so you should:
* start with a fresh checkout
* use the patch for the master branch that I published today
If that fails, send me an e-mail.
January 24th, 2011 - 02:24
Okay all the patches did not work for me again with this error.
Could you tell me what the contents of this file should be I could try to do it manually.
sudo patch -p1 -d external/qemu/ < android_imei_patch_tools_r8_20110122.diff
patching file android/avd/hardware-properties.ini
Hunk #1 FAILED at 150.
1 out of 1 hunk FAILED — saving rejects to file android/avd/hardware-properties.ini.rej
patching file android/avd/hw-config-defs.h
Hunk #1 succeeded at 227 with fuzz 2 (offset 77 lines).
patching file android/avd/info.c
This is the reply I got for all three the other file patching seem to work.
January 24th, 2011 - 10:54
I’m slightly lost about which version you’re using – if you don’t mind, what exact command did you use to checkout the repo?
January 24th, 2011 - 15:46
This is the patch command I tried all versions above
———————————
sudo patch -p1 -d external/qemu/ < android_imei_patch_tools_r8_20110122.diff
repo commands used
—————————
sudo time repo sync
this is the android command
————————————-
sudo -s repo init -u git://android.git.kernel.org/platform/manifest.git -bdonut
January 24th, 2011 - 18:55
Now it’s clear – you’re using Donut branch, i.e. Android 1.6, while my patches are for Froyo (Android 2.2) and higher. I can backport the patch, but.. just my curiosity – why do you need such an old version?
January 25th, 2011 - 16:33
http://blog.codepainters.com/2009/12/18/first-android-platform-build/
You have not updated one of your post, and I clicked previous post from this page below
http://blog.codepainters.com/2010/10/27/compiling-android-sdk-on-ubuntu-10-10-maverick-meerkat/
January 25th, 2011 - 16:35
Ah, that post was from 2009, its’ pretty much outdated now. I guess I should at least add a link to a newer post there
How’s the patch? Did it work for you eventually?
January 25th, 2011 - 17:57
Also where is there a list of versions you can get, I can not find froyo. is it -bfroyo
or just -froyo.
I have not been able to get froyo release or any release yet, I cannot build android. This shit has taken me a week just to test serial numbers. I am never programming for mobiles after this program. I can not believe they would make it so difficult to do so little.
January 25th, 2011 - 21:17
Well, Android development is moving forward very quickly, sometimes at the cost of code quality (I’ve seen a lot of hacks inside Android code). The documentation cries for improvements as well.
I hope you’ve seen that page already?
http://source.android.com/source/download.html
I can send you exact steps to do, but I suggest you rather contact me via email (I’ve sent you an email, so you have my address), I don’t want to continue this topic in blog comments endlessly.
March 31st, 2011 - 08:24
The path imformation was a great help. But when the IMSI’s MCC or MNC is change from 310260, the emulator doesn’t have network access.
Any idea how to change these and still have network access?
October 18th, 2011 - 05:33
hi Sig250,
i have the same confusion with you.
How can you figure it out?
Thanks!
August 15th, 2011 - 17:36
How can I modify the model (android.os.Build.MODEL)
September 16th, 2011 - 02:57
The patch doesn’t work if you want to use a MEID value, as those start with a hex digit, and in reference-ril.c, it uses at_send_command_numeric() to retrieve the value instead of at_send_command_singleline().
December 19th, 2011 - 10:45
Hi, meets from Spain.
Ive tried do this, but this post its seem to be obsolete..
Sometimes Im traveling and Id like to have a clone of my Samsung Galaxy SII or my HTC Desire for use without roaming (whatsapp,grindr,badoo, etc)(on my PC) so I need change IMSI, IMEI, Number of the emulator, but I have 2.3.3 , your DIFF doesn’t work with this version. I have the SDK downloaded this weekend, could you help me please?.
Thanks in advance.
February 22nd, 2012 - 00:46
Hi admin .. tnx a lot for your job… i successfully build an emulator with your froyo patch.
but I have a problem… internet connection didn’t work on emulator. Is there a way to make the emulator connect to the web with your patch? or can you tell me what file I have to modify manually in order to change imsi and sim?
regards
March 4th, 2012 - 13:23
Hi! Thanks for pointing the issue, I’ve just reproduced it. I’m a bit surprised, as I’ve created this patch to test my application, which uses TCP connections a lot – and it was working just fine! It was several months ago, however, something might have changed since then.
There’s a good news however: it seems that if you only change IMEI and do not enforce IMSI/SIM serial, network appears to work fine! To be exact, it seems everything works just fine if IMSI starts with 310260 !
I hope this helps you!
March 5th, 2012 - 11:45
tnx admin! yes I tried and it works just fine, also with hw.gsmModem.imsi=310995000000000
now I have another question 4 U : is there a way to change the read-only variable ro.kernel.qemu=1 to =0 ? I want to change this value to bypass the emulator check that some android apps do to know if you are using an emulator or a real device
it is possibile to do that?
tnx again
March 5th, 2012 - 12:10
Well, it is possible for sure, yet depends on how particular application checks for the emulator. Are you sure ro.kernel.qemu has anything to do with it? What is the application you want to cheat?
March 5th, 2012 - 12:41
realy?
wow! I tried to change imei, IMSI, simSerial, android_ID … but nothing. with the emulator I can’t play on this app (Gowar)
can I have your mail please ?
May 29th, 2012 - 11:53
Hi,
Thx for the patch it really work well for Froyo.
Did you try this on ICS ?
Thx a lot
May 29th, 2012 - 11:58
No, unfortunately I have not tried it with ICS. Are there any problems applying it on ICS?
May 29th, 2012 - 13:26
Yes some files are different and there is no android/avd/hardware-properties.ini
I tried to fix it but did not succeed…
May 29th, 2012 - 13:26
Sorry it’s android/avd/hw-config-defs.h which is missing
May 29th, 2012 - 17:41
It seems this part of code is not very stable, my patch needs frequent updates. I’ll take a look, thanks for reporting!
May 30th, 2012 - 01:47
I’ve just added the update patch, working with release labaled as 4.0.4. Actually the patch is slightly simpler now, Google guys fixed a few minor issues in their code.
Let me know if it works for you!
May 30th, 2012 - 11:08
Works perfectly Thx
August 28th, 2012 - 05:08
I’m an idiot and I cannot seem to figure this out… I’ve figured out how to build an ICS emulator, I just cannot figure out how to apply the damn patch.
I’m a noob to ubuntu, I’ve had the opportunity to use it… lots, just never any need to.. I’ve built android emulator in windows before and played around with coding, but this is the first real time I’ve messed with linux.
so could you write it out in plain english the command I need to type to apply this patch to my sdk and then what to compile it
thanks… it’s late and it took me all damn day to get the SDK downloaded and all the prereqs installed.
August 28th, 2012 - 07:42
for some reason now the android list command isn’t working I get an error saying android isn’t a command. I’ve gone into the android-sdks/tools folder… it was working, I restarted my laptop and now it’s not.
god this is frustrating, I know it’s something stupid simple I’m doing that’s not working… something really simple I’m overlooking.
I’ve even created an avd THROUGH eclipse and played with it, I just can’t find it anywhere…. I know I should’ve used linux years ago when I started using litestep and playing with kernels in windows 98.
September 3rd, 2012 - 16:55
Well, how come you managed to actually *build* the emulator having problems with SDK configuration?
September 4th, 2012 - 17:23
I didn’t build the emulator through the terminal I built it inside eclipse the same way I would with windows.
I’ve found where the files are kept, I just can’t figure out how to apply the patches. I downloaded the entire source tree it was close to 20 gigs I’ve found some of the files I just cannnot apply the patch cause apparently I’m an idiot.
September 5th, 2012 - 14:15
I guess what you mean is creating AVD instance and not actual emulator compilation? As of patching, well… http://linux.die.net/man/1/patch
September 6th, 2012 - 18:25
this is the problem I’m getting now, I’ve got the entire source downloaded to home/source-dl/
nicholas@ubuntu:~/Desktop$ patch -p1 < android_imei_patch_4_0_4.diff
can't find file to patch at input line 5
Perhaps you used the wrong -p or –strip option?
The text leading up to this was:
————————–
|diff –git a/android/avd/hardware-properties.ini b/android/avd/hardware-properties.ini
|index a2b05df..10ede3c 100644
|— a/android/avd/hardware-properties.ini
|+++ b/android/avd/hardware-properties.ini
————————–
File to patch: a
a: No such file or directory
Skip this patch? [y] y
Skipping patch.
1 out of 1 hunk ignored
can't find file to patch at input line 37
Perhaps you used the wrong -p or –strip option?
The text leading up to this was:
————————–
|diff –git a/telephony/android_modem.c b/telephony/android_modem.c
|index 437035d..f88a817 100644
|— a/telephony/android_modem.c
|+++ b/telephony/android_modem.c
————————–
File to patch: y
y: No such file or directory
Skip this patch? [y] y
Skipping patch.
7 out of 7 hunks ignored
can't find file to patch at input line 134
Perhaps you used the wrong -p or –strip option?
The text leading up to this was:
————————–
|diff –git a/telephony/sim_card.c b/telephony/sim_card.c
|index b172deb..a65f23e 100644
|— a/telephony/sim_card.c
|+++ b/telephony/sim_card.c
————————–
File to patch: y
y: No such file or directory
Skip this patch? [y] y
Skipping patch.
5 out of 5 hunks ignored
September 3rd, 2012 - 16:42
Dear admin, have you even researched how to change the phone number in the emulator.exe ?
Does the SIM Card Series have relationship to the phone number ?
I am looking forward to your reply, Thank you!
September 3rd, 2012 - 16:53
No, I’ve never tried hacking the phone number. Actually, the phone logs into the network with IMEI and IMSI, and this is the network side that assigns/maps the phone number (known as MSISDN) to/from particular IMSI. Many phones don’t even know their own number.
That said, I’m not sure about Android – never needed it for anything.
September 4th, 2012 - 05:34
Thanks First.
But i find that whatever how many emulators you created, they have the same phone number.
So , i wonder if the source code of the emulator contains the phone number
If this if true , theoretically, we can use hex editor to find it and change it
December 4th, 2012 - 23:25
Hello Dear Admin
I have sucessfully modded the Phone Number.
If you want,i can share it to the community of your site,if there is still someone who needs this.
Contact me if you still doing research on this topic. If not,you may delete this post.
Best Regards
Ilia
December 17th, 2012 - 15:50
Hi, im not able to compile this.. could you send me and emulator compiled?
December 17th, 2012 - 17:55
Add following line to config.ini
hw.gsmModem.phonenumber=
and use following Emulator.exe(replace original)
Unfortanatly it isnt quite useful,beacause it doesnt show the + code,and i havent managed to change this. So it only change the phonenumber
Download
http://www.file-upload.net/download-6939464/PHONENUMBER-PATCHED.rar.html
December 19th, 2012 - 13:55
Sorry , I dont know whats the problem.. i use your exes, create a new virtual,
3.2 ” QVGA (ADP2).
Android 2.3.3 API LEVEL 10
My folder are:
C:\Users\Jose Antonio\AppData\Local\Android\android-sdk\platforms\android-10\images
C:\Users\Jose Antonio\AppData\Local\Android\android-sdk\platforms\android-10\skins\QVGA
and my config.ini is :
skin.name=QVGA
image.sysdir.1=platforms/android-10/images/
skin.path=platforms/android-10/skins/QVGA
hw.gsmModem.imei=123451234512345
hw.gsmModem.imsi=543215432154321
hw.gsmModem.simSerial=11223344556677889900
hw.gsmModem.phonenumber =34608729317
But my android, on settings shows number :1-5555xxxx , and IMEI 0000000
February 4th, 2013 - 11:41
i need urgent help…..can you please post a complete tutorial or all codes that can give a demo of android application that displays imei number of a device (emulator or android device)
February 4th, 2013 - 19:07
I’ve linked such an application in the post, read carefully, please