[Android Software Development] iBotPeaches:
Okay, I duplicated.

W/ActivityManager( 706): No content provider found for permission revoke: file:///data/local/tmp/systemGmail.apk
D/Finsky ( 1873): [1] PackageVerificationReceiver.checkPrerequisites: Skipping verification because network inactive
D/dalvikvm( 894): GC_CONCURRENT freed 363K, 42% free 11272K/19340K, paused 1ms+2ms, total 21ms
W/ActivityManager( 706): No content provider found for permission revoke: file:///data/local/tmp/systemGmail.apk
I/PackageManager( 706): Copying native libraries to /data/app-lib/vmdl1711910577
W/PackageManager( 706): Invalid verification token 1 received
W/PackageParser( 706): /data/app/vmdl1711910577.tmp (at Binary XML file line #543): <provider> does not include authorities attribute

I re-decompile the compiled apk, and ran a diff against the AndroidManifest and they are the same. This made me wonder why this APK was borking. So I I tried a `adb install app.apk` command of the original and rebuilt apk.

ibotpeaches@raganok:~/Downloads/Apktool/Gmail$ adb install systemGmail.apk
4710 KB/s (4256390 bytes in 0.882s)
pkg: /data/local/tmp/systemGmail.apk
Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]

So the apk that was uploaded a few days ago is not pure. Skip that one. Move on.

So I went to the playstore on a freshly system wiped 4.3 d2att CM rom. Downloaded Gmail, pulled Gmail. System Wiped my phone. Rebooted.

I tried to install it, no problems. So we at least knew this apk worked. Decoded apk, modified res/values/strings and res/values/values-en-rGB/strings.xml and recompiled with -c flag.

Install it via adb.

W/ActivityManager( 2349): No content provider found for permission revoke: file:///data/local/tmp/com.google.android.gm.apk
W/PackageParser( 2349): /mnt/asec/smdl2tmp1/pkg.apk (at Binary XML file line #543): <provider> does not include authorities attribute

3506 KB/s (4256784 bytes in 1.185s)
pkg: /data/local/tmp/com.google.android.gm.apk
Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]

So dammit. We have a problem. Or maybe, yes I've duplicated the problem. I took a look around the bugs, and I closed one relating to this exact error: http://code.google.com/p/android-apktool/issues/detail?id=519

What blows my mind is that the APK prior to compilation has the authorities attribute, as can be seen here:

<provider android:authorities="gmail-ls" ..... </provider>
<provider android:authorities="com.google.android.gm"..... </provider>
<provider android:authorities="com.android.gmail.ui"....</provider>
<provider android:authorities="com.google.android.gmail.SuggestionsProvider"...</provider>

They are all strings hardcoded. No resource [MENTION=936943]string[/MENTION] identifiers, so that throws out one of my ideas. Somehow between the compilation of the manifest back to binary form, a mistake is occurring. So I thought I would trick the system and simply move my modified resources.arsc file back into the unmodified clean Gmail.apk, and install that.

So I did.

ibotpeaches@raganok:~/Downloads/Apktool/Gmail$ adb install com.google.android.gm.apk
3379 KB/s (2827698 bytes in 0.817s)
pkg: /data/local/tmp/com.google.android.gm.apk
Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]

(yes logcat showed same <provider> error)

WHAT! I didn't even touch the Manifest. This was an apk that literally just installed 5 minutes ago. All I did was add my modified resources.arsc file via 7zip.

I thought I had to be wrong. Downloaded new clean apk.

ibotpeaches@raganok:~/Downloads/Apktool/Gmail$ adb install com.google.android.gm_clean.apk
4313 KB/s (4253876 bytes in 0.963s)
pkg: /data/local/tmp/com.google.android.gm_clean.apk
Success

All was good. So I double checked and moved my modied resources.arsc that was built via Apktool into that clean apk, then installed it.

3932 KB/s (2827698 bytes in 0.702s)
pkg: /data/local/tmp/com.google.android.gm_clean.apk
Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]

again :( Everytime it was the same "(at Binary XML file line #543): <provider> does not include authorities attribute".

So I'm at a lost of words. I quickly grepped for <provider> in the decompiled sources. Sure enough, only the manifest is taking hits. The manifest is causing the problem according to ADB, but I never changed the Manifest in any of these examples. I always used the original binary one.

Hell, even the time I downloaded a fresh new APK and copied the modified resources.arsc without doing anything caused the problem. So I guess we have found a problem, but how? where? and why? Is still up in the air. Obviously if the only file changed is resources.arsc, then the problem must be there.

Messing around with this APK is a horrible test-suite though. I will make a test-apk using the authority attribute, with like 1-2 strings and work with that one to help eliminate variables.

Guess we have a project among of us now. I recommend anyone interested in this issue to join our irc channel #apktool on freenode. I like talking things out and doing this in a huge post like this, might be annoying to read. Off to bed, glad we finally duplicated together.