yashsingh1/xdaforums huggingface dataset:
[Galaxy S II Themes and Apps] Doku:
Didnt work on stock Xperia ZL 4.4.2

This is the exception i receive when i run the script on stock 4.4.2 on Xperia ZL

Checking device...

Model: C6502, build 10.5.A.0.230, android 4.4.2 (API Level 15)

/system mounted on /dev/block/platform/msm_sdcc.1/by-name/system, mode ro

checking root access. root uid: 0, secure: yes, busybox: no

Pulling app(s) ...

Can't find Email app. Enter the name of your Email apk or press <Enter> to exit: semcemail.apk

Pulling libs ...

Decompiling Exchange2.apk ...

java.lang.reflect.InvocationTargetException

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at jpatch.emailPolicy.Run.runIsolated(Run.java:922)

at jpatch.emailPolicy.Run.applyPatch(Run.java:551)

at jpatch.emailPolicy.Run.main(Run.java:700)

Caused by: org.jf.dexlib2.DexFileFactory$NoClassesDexException: zip file Exchange2.apk does not contain

le

at org.jf.dexlib2.DexFileFactory.loadDexFile(DexFileFactory.java:68)

at org.jf.dexlib2.DexFileFactory.loadDexFile(DexFileFactory.java:54)

at org.jf.baksmali.main.main(main.java:247)

... 7 more
[Galaxy S II Themes and Apps] aHcVolle:
had the same problem on my win7 x64 machine...

After a few retries it worked correctly. I'm not sure if this is the same problem you have because i had many different errors, even the "checking root access" failed several times..
[Galaxy S II Themes and Apps] rustyx3:
Switched to another patching approach (patching isActive() and isActiveAdmin()), which should hopefully work better for different devices, including 4.0.3 ICS.

Lemme know if version 2.0 works better. See first post for the patch.
[Galaxy S II Themes and Apps] CaspaTheGhost:
Havent been able to use the apk referred to by a previous user, force closes on my device as my rom has the Google prefixed email and exchange apks so gonna give this a try...
[Galaxy S II Themes and Apps] ironicsky:
Success!... Sort of

Thank you so much for the updated installer. This one, like the others has the same difficulty of needing to be re-run repeatedly until it works, small price to pay to NOT have my employer controlling my personal phone that I happen to use for work purposes!

On this one, it failed to copy the Email.apk to the phone, log is below. But that didn't matter, I just copied it over manually and dropped it in place, works like a charm.

I am going to try it again at work this morning to see if its my computer. At work I have the Android Developer SDK installed with the Google USB Debug drivers, so who knows.

Do you take donations for your contributions? I'll paypal you a token of my appreciation.

Cleaning up ...
Waiting for USB connection...
Checking device...
Model: SGH-I997, build MIUI.1.12.23, android 2.3.7 (API Level 10)
/system mounted on /dev/block/stl9, mode rw
checking root access. root uid: 0
Pulling Email app ...
Pulling libs ...
Decompiling ...
Applying patch ...
Patching method isActive(Lcom/android/email/SecurityPolicy$PolicySet;)Z
Patching method isActiveAdmin()Z
Recompiling ...
Building Email.apk ...
Updating device ...

*** Unable to upload Email.apk. Is there sufficient space on /sdcard?

Windows 7 Ultimate, 64Bit

Java Runtime 6.0.3

Kies Version 1.0.0.413

8.8Gb free on /sdcard
[Galaxy S II Themes and Apps] rustyx3:
welcome :D

Well, the script is stable on my system; Vista, 32bit, Java 7. And I have Kies uninstalled, kept only the drivers... You can try upgrading to Java 7, or temporarily stop Kies. See if that helps. Also if you get it to fail at an earlier stage, it will print the actual adb output, that output can provide some extra clues.
[Galaxy S II Themes and Apps] CaspaTheGhost:
Haven't had a chance to give this a try yet but I'm hoping it will work for me to!
[Galaxy S II Themes and Apps] CaspaTheGhost:
gonna give this is a go now, just gotta sort the drivers on my laptop as they seem to have stopped working as no device recognised...

---------- Post added at 02:26 PM ---------- Previous post was at 02:15 PM ----------

No joy for me as it fails to pull the apk... Sure it's due to the fact that my ROM has the EmailGoogle.apk along with the ExchangeGoogle.apk...

Any workaround for me as all of the apk's out there don't work for me, they all force close..

For reference, I'm using this ROM on my Galaxy Nexus...
[Galaxy S II Themes and Apps] nikzDHD:
Thanks mate, this is excellent worked fine on Checkrom V5.
[Galaxy S II Themes and Apps] DarkDvr:
UPDATE:

Rustamabd has updated the patch. As of v2.1, there's no need to do what I mentioned below to update the Email APK in ICS.

Simply follow the instructions in OP.

rustamabd

Email patch worked for 4.0.3 ICS!!

You got a paypal address where I can donate? =)

For those who want to patch their ICS, here's the deal:

There are 2 email apks - EmailGoogle.apk and ExchangeGoogle.apk.

Here's what worked for me:

Backup both APKs with Root Explorer

Rename EmailGoogle.apk to Email.apk

Run rustamabd's patch

Phone will reboot.

After reboot, launch Root Explorer, rename Email.apk back to EmailGoogle.apk

Another reboot may be needed to pick up the new Email.apk

Register, enjoy!

rustamabd, as a suggestion, you may modify your batch file to patch EmailGoogle.apk when no Email.apk is available.

If this post helped you, use "thanks" button =)
[Galaxy S II Themes and Apps] shaoming90:
thx for sharing~~~~
[Galaxy S II Themes and Apps] rustyx3:
Patch updated!
[Galaxy S II Themes and Apps] CaspaTheGhost:
Fantastic stuff, but damn, left my laptop at the office!

I'll be giving the updated patch a try tomorrow then!
[Galaxy S II Themes and Apps] CaspaTheGhost:
Ok, just applied the patch and all went smoothly... Gotta get out the office so gonna set up the work account on my way home so will report back shortly...

Not working at the moment, initially worked and asked to activate the security so I accepted and then simply cancelled out before setting a PIN... It then sat waiting to sync but nothing happened... So I deleted the account and tried again and now its says 'Couldnt finish - Couldnt open connection to server'...

Gonna restore my backup and try again...
[Galaxy S II Themes and Apps] TBolt4Now:
Is this supposed to work on the Samsung Galaxy Nexus? Unfortunately, I couldnt get it to work on my 4.0.2 galaxy nexus CDMA. My company requires the "unsigned installation packages" policy and after patching/attempting to add account, I get this error:

"This server requires security features that your Android device doesnt support, including: null"

any other way to spoof that policy?
[Galaxy S II Themes and Apps] tcortinag:
Works like a charm! SGSII with ICS 4.0.3
[Galaxy S II Themes and Apps] CaspaTheGhost:
Didnt work on mine, the patch ran with no issues but the policy is still forced... Noticed that there was EmailGoogle.patched.apk on the root of the SD so replaced the one in system with it but still the same, policy forced...
[Galaxy S II Themes and Apps] rustyx3:
that's weird, the script couldn't update the system app (the last step). Rename EmailGoogle.patched.apk to EmailGoogle.apk and move it to /system/app (looks like you already did). If you also have an .odex file in /system/app, delete it (don't forget to make backups!).
[Galaxy S II Themes and Apps] CaspaTheGhost:
Yeah, already renamed and moved it but still no joy. Also just checked for an odex file but nowt.

Still has the policy enforced.
[Galaxy S II Themes and Apps] medzed:
Could someone write a step by step tutorial how to patch the existing apk ??
[Galaxy S II Themes and Apps] CaspaTheGhost:
UPDATE:

ROM I'm using had an update so I thought I'd give it a go again! Cleared Cache and Davlik, installed the new ROM, then the Gapps package...

Then ran the patch again and it all went smoothly, checked and my account was no longer there so I changed the security settings to have slide unlock...

Checked the SD and the patch couldn't write to system again so I renamed the patched apk and moved it to system, rebooted and then setup the account...

All went fine, no mention of security policy at all, didn't sync at first as it said it couldn't connect to the server, but left it for 5 minutes and hey presto...

I'm back with my corporate account and no security so I can take full advantage of the quad unlock!

Thank you for this, it's a great bit of work!
[Galaxy S II Themes and Apps] sordna:
Has anyone tried both Mail Wise and Nine ? I understand both offer bypassing device lock, but how do they compare as email apps?
[Galaxy S II Themes and Apps] carpe07:
Hi,

Is this hack also working with AOSP 4.4.4 Rom (e.g. Neatrom 6.4.1 for I9300)?

I have modified the two apps mail.apk und exchange2.apk manually, but when adding an exchange account it will add mail to security - system administrator?

In the past I have done it this way without any problems ( 4.3 ROM)...

Thanks
[Galaxy S II Themes and Apps] os2baba:
I haven't used Nine. But since I wasn't able to get this hack working on the LG G2, I started using MailWise. That certainly works. There are still a few rendering issues. But by and large, it's a pretty good mail app.
[Galaxy S II Themes and Apps] cschmitt:
I use Nine, it's the best mail app for exchange I've every used. It has tons of features not available in AOSP Email and the application level security model lets admin security apply to the Nine only (i.e. a remote wipe only clears the apps data, and a pin code restriction only applies to accessing Nine.) The developers are continually adding new features, like Tasks and Notes support for an upcoming release.
[Galaxy S II Themes and Apps] fastguy:
Yes I agree Nine seems to be the best these days. Touchdown still has more features though, such as being able to define the amount of data to download for each mail. Issue with Nine for some is that it only supports Activesync and nothing else (ie no imap).
[Galaxy S II Themes and Apps] cschmitt:
Nine supports selecting the email download size, but didn't realize it was ActiveSync-only until you mentioned it, which is all I use it for.
[Galaxy S II Themes and Apps] MrNetwork:
Outstanding patch!

This worked for me. Galaxy Note 2 with N3BULA rom. Since this decompiles, patches and recompiles the two email apk's, I backed up a copy for the future in case of a crash.

The main reason I wanted this is to be able to have one calendar that shows my Google calendar and my Exchange calendar.

I still use security on my phone but the way I want it.

Thanks for creating this.
[Galaxy S II Themes and Apps] lightlytoasted:
Andoid L Nexus 5 works

I've been using your bad !@# patch tool for a long long time now. Figured I should donate again.

Donate to keep this dev going!! I can't live with my exchange required 7 DIGIT NON-REPEATING PIN!!!

Thanks so much rustamabd
[Galaxy S II Themes and Apps] alien0101:
patch for 4.4.2 samsung note3

will this patch work for Note3 with 4.4.2 android version?

I can see there are patches for 4.3 and 4.2 but none for 4.4.2
[Galaxy S II Themes and Apps] fastguy:
Yes it did work for my Note 3 4.4.2. But It was not the latest firmware. Just give it a try.
[Galaxy S II Themes and Apps] Shahan_mik3:
Cool if only it was available for kitkat :)
[Galaxy S II Themes and Apps] rand79:
didn't work with my Galaxy S5

from the procedure perspective everything worked.

the phone rebooted and all but the Email shortcuts wasn't deleted and I still need to enter the pin code...

anyone have a solution?
[Galaxy S II Themes and Apps] xnappo:
Thanks - but Gear 2 protection removal possible?

Thanks a lot for this. Finally rooted my Note 2 after two year of putting it off.

My main goal was to get access to my emails on my Samsung Gear 2 Neo - however while the hack successfully disabled the pin lock, I still can't real my emails on my watch.

Any chance this could be fixed?

xnappo
[Galaxy S II Themes and Apps] sordna:
Why don't you use Nine (free trial, then paid) or Mailwise (free) ?

Both of these apps allow you to access corporate email without a keyguard on your device.
[Galaxy S II Themes and Apps] xnappo:
Tried both, but they only have the subject and a line of text at best, or just the number of new messages at worst.

The stock client has the full message.

EDIT: oops see you were not talking to me :D

xnappo
[Galaxy S II Themes and Apps] virtualspeed:
Hello,

Can you fix this? or is the problem somewhere on my side?

The previous versions can access/connect to the phone without any problem.

I did the instructions below already a lot of times for many pcs and other applications in the pc have adb access to the phone without any problem.

the phone I have is a BQ E5 FHD with android 4.4.2 with a mediatek cpu.

EDIT: forget this post. The version of the adb I had was too old.

but now it's giving me this errors.

Cleaning up ...
Found adb on PATH.
Waiting for USB connection...
Connect your device!
Enable USB debugging (Settings -> Applications -> Development -> USB debugging)
On CM builds allow ADB root access (Settings > Developer Options > Root access)
Authorize PC access on device if necessary (check device screen)
[Galaxy S II Themes and Apps] blulite:
Been using on my S5 with 4.4.2 since release of S5. I just upgraded S5 to 4.4.4 and reapplied patch and all still works.
[Galaxy S II Themes and Apps] virtualspeed:
Can you or someone else send me the modified email.apk?

I'm not sure if I need also the exchange.apk

I'm unable to use the patch on my phone. It show always the errors above and the apk is not patched.
[Galaxy S II Themes and Apps] newyankee:
S4mini, not working this time

I have used the patch on S3mini and S4mini up to 4.4.2 XXUCNE6 successfully. I have now updated to XXUCNH5, rooted the phone using the procedure described here .

Now, I can't apply the patch, all just stops here:

Cleaning up ...
Waiting for USB connection...
Checking device...
Model: GT-I9195, build KOT49H.I9195XXUCNH5, android 4.4.2 (API Level 15)
_

and nothing ever happens. There is no debug log written.

EDIT:

Success.

Uninstalled and re-installed super-su. This allowed the extraction of the both apk's . Then I had to go down the manual route, because some permissions were not properly set. Rooting without triggering knox has become more difficult after the last updates....

Finally, after moving the patched files into \system\app and properly setting their permissions manually, e-mail works fine.
[Galaxy S II Themes and Apps] ascertainer:
hi folks,

on my n9005 with firmware GNG1 the patch seems to be working (runs without error messages) but when its done the mail apk crashes (stopped).

has any other the same problem?
[Galaxy S II Themes and Apps] schitthoch2:
Try to disable USB debugging and re-enabling it when your phone is disconnected from the PC. Then re-connect it and you should get an fingerprint message and inital Super-Su initiation.
[Galaxy S II Themes and Apps] Grouxho:
Thanks for this mod.

[emoji1]
[Galaxy S II Themes and Apps] evanovici:
OnePlus

It doesn't work for me on the Oneplus One, CM 38R, I've checked off and on for several times usb debugging, but getting the same error:

Cleaning up ...

Found adb on PATH.

Waiting for USB connection...

Connect your device!

Enable USB debugging (Settings -> Applications -> Development -> US

On CM builds allow ADB root access (Settings > Developer Options >

Authorize PC access on device if necessary (check device screen)

Also tried with CM SU and SuperSU...

Any ideas?

Thanks
[Galaxy S II Themes and Apps] greatg:
Wondering if anyone with a Note 4 has been successful in applying this hack?
[Galaxy S II Themes and Apps] virtualspeed:
I gave up on it already. I use enhanced email app now.

No need for pins.
[Galaxy S II Themes and Apps] Hossy923:
[MENTION=2246637]evanovici[/MENTION]: Can you connect to your device with adb normally? If you can't, fix that and the script should work.

---------- Post added at 09:15 AM ---------- Previous post was at 09:12 AM ----------

Is it failing? There's no harm in just blindly trying. It has a backup and restore feature. :)
[Galaxy S II Themes and Apps] virtualspeed:
I have now also a One Plus One and couldn't patch it properly anyway.

I had no "enable usb debugging" warnings this time, it all seemed to work fine but in the end the app was forced closing always.
[Galaxy S II Themes and Apps] blackShawarma:
Works for Note 4 running 4.4.4!

Just finished rooting and applied this, and it worked like a charm!

I did have to tell it how to find the email app though, when it says it can't find it, type:

SecEmail_K.apk

And the rest worked automatically.

FYI I found the email app with:

adb shell 'pm list packages -f' | grep -i "Email"

Thanks OP!
[Galaxy S II Themes and Apps] greatg:
Did you use 4.2 or 4.3? What do you mean - FYI I found the email app with:

adb shell 'pm list packages -f' | grep -i "Email"
[Galaxy S II Themes and Apps] rhodry999:
New gmail with exchange

Today Google started rolling out a new gmail app (v5) + new exchange service 6.5. From now on its possible to use gmail with exchange as well. I guess many of us are interested if the new gmail app and exchange services can be hacked as well. We all know that with Lollipop Google is tightening the security once more again.

I understand it might take awhile before anybody finds out what the possibilities are. But fact is I really like the idea of having one app for all my email. And the new gmail app looks great!
[Galaxy S II Themes and Apps] virtualspeed:
have you changed the recovery to properly root it?
[Galaxy S II Themes and Apps] marcyspark:
I tried applying this patch with the Gmail2.apk but it didnt work. Gutted.

Just about to see if Wanam exposed policy hack works - brb

Guess what? That doesnt work either - I'm going to go back to my hacked SecEmail_K on my Note 4 for now. This Gmail5 app rocks though.
[Galaxy S II Themes and Apps] f10a:
Anyone try this with 4.4.2 TW ROM? or have a compatible solution?
[Galaxy S II Themes and Apps] drjat:
I have successfully used this on touchwiz 4.1.2, 4.3, 4.4.2 and 4.4.4 ROMs
[Galaxy S II Themes and Apps] evanovici:
[MENTION=1731758]rustamabd[/MENTION], can't live without your mod, thanks for the great job!

As all of us are eagerly waiting, do you have any plan to make it work with the 5.0 Gmail app?

TIA!
[Galaxy S II Themes and Apps] brandoncampbell:
confirmed it does work. I had to remove my pre-existing exchange services and install the new one from google. It asked me to find both the email client and exchange service. now I my work email through google.
[Galaxy S II Themes and Apps] drjat:
Please share more information on how you made it work. A tutorial would be even better. There are a lot of people looking forward to this. Many thanks in advance.
[Galaxy S II Themes and Apps] slavislavi:
Patched properly but really ignores security? Did you check?
[Galaxy S II Themes and Apps] rhodry999:
Great. It does work. I had to use Titanium backup to integrate the exchange services in rom en delete the old exchaneg services. I also integrated the gmail app in rom.

after that run the patch and it works.
[Galaxy S II Themes and Apps] mcfisch:
Want to add that flashing the modified AOSP files to my Note 10.1 2014 on CM11 replacing the existing 4.x Email/Exchange apps also worked flawlessly.

BTW, the flashable ZIP I've uploaded there.
[Galaxy S II Themes and Apps] edgarf28:
Is there any way to make the patch compatible with the ART Runtime?

Because when I apply your patch when I'm on ART then my Mail app gives an FC at start an won't work.
[Galaxy S II Themes and Apps] chrispy_212:
Have installed and then patched the AOSP email app on my M8 GPE running Lollipop, thanks so much! Now I can use Smart Unlock and still have my work emails!

I'm having trouble getting it to work with Gmail though. I've apparently patched Exchange3Google.apk successfully (subsequent runs of the script return that the apk is already patched) but now my option to add Exchange accounts to Gmail is missing. I'd really appreciate some help, thanks!
[Galaxy S II Themes and Apps] Kun2210:
You need another Exchange.apk, the one that comes along with new Gmail. Then you need to patch it as well. Once installed (and probably after reboot) you'll see Exchange in gmail back.

Wysłane z mojego GT-N7100 przy użyciu Tapatalka
[Galaxy S II Themes and Apps] chrispy_212:
Thanks for your help. I've been trying to patch the Exchange3Google apk that came with Lollipop for my device, are you suggesting I replace that with a different binary (from androidpolice or similar)?
[Galaxy S II Themes and Apps] Kun2210:
I used the one from Android Police.
[Galaxy S II Themes and Apps] chrispy_212:
Hmm, I just downloaded one of their APK's, namely version 6.5-1520254, and I still have the same issue. If I hide Email.apk and Exchange2.apk from the script, it asks for the paths to Email and Exchange. I give it Gmail2 and Exchange3Google, and it apparently patches the latter successfully. It does, however, fail to push the patched apk, which I do manually, it seems to be an issue with root permissions; if I use 'su' an additional time, I get write permission to /system.

But, I still don't have the option for exchange accounts in Gmail!
[Galaxy S II Themes and Apps] Kun2210:
Did you set rw--r--r permissions on pushed APK?
[Galaxy S II Themes and Apps] chrispy_212:
That did it. Thanks so much!
[Galaxy S II Themes and Apps] MustGoFast:
Which app is that?

Anyone know a way to do this on the new Droid Turbo... I love that phone and would like it, but if I can't do this it's a NO. (ie can it be done without root?)....
[Galaxy S II Themes and Apps] virtualspeed:
https://play.google.com/store/apps/details?id=com.qs.enhancedemail.tablet
[Galaxy S II Themes and Apps] MustGoFast:
Is there a security bypass in this, or do you hack this instead which in theory wouldn't require root?
[Galaxy S II Themes and Apps] XGrzesiuX:
Lollipop Update

I was wondering if anyone is working on update for Android L 5.0. I have Samsung S5 and i just updated to Android L and the Hack is not working anymore. Thanks in advance.
[Galaxy S II Themes and Apps] tdunham:
It probably isn't going to work if your version is still odexed. And we can't deodex L yet.
[Galaxy S II Themes and Apps] virtualspeed:
yes, security bypass.
[Galaxy S II Themes and Apps] pentafive:
Thankfully the trusted devices (like bluetooth) will remove the pin requirement on Android L even with an exchange policy. Use this with my pebble to keep the pin off while connected.
[Galaxy S II Themes and Apps] sordna:
Really? So all you need is a Bluetooth headset, or maybe an NFC tag glued to the phone underside and no more PIN ??? :)
[Galaxy S II Themes and Apps] pentafive:
In Lollipop? Yep! It is called 'Trusted Devices'. Any connected and 'trusted' bluetooth device will not require security to unlock the phone. I use my pebble and my car. The NFC option is more like a switch. You register a tag and when the phone reads the tag will unlock. Keeping the tag there won't prevent it from locking.

Here is some more info: http://www.androidpolice.com/2014/10/20/lollipop-feature-spotlight-smart-lock-includes-trusted-bluetooth-and-nfc-devices-that-let-you-skip-the-lock-screen/
[Galaxy S II Themes and Apps] tbo01:
Many thanks!

mcfisch, you made my day! Many thanks :highfive:

Did it like described, works perfectly on S4 with Danvdh-GPE-5-12172014 ROM.

Cheers

Thorsten
[Galaxy S II Themes and Apps] Kun2210:
For those who want to use this on Lollipop - I've made it to work on CM 12 (5.0.2) by simply manually poiting to Exchange apk.

What I did was I run the apply-patch.cmd, and once it did not found the apks, it wants to point it to the files.

For Email.apk I wrote: PrebuiltGmail/PrebuiltGmail (there's no need to patch this one anyway)

For Exchange.apk I wrote: PrebuiltExchange3Google/PrebuiltExchange3Google (this one went OK). I had a problem with root detection, so I manually switched the patched exchange file and voila! Works flawlessly :)