[Android Software Development] TheDestroyer:
Need help to modify the apk

Hello everyone, I've read a lot and tried a lot and now I need some help.

My device: SGS3 GT-I9300

OS version: JB 4.1.2

Stock flash: I9300XXEMB5

The aim of apk modification:

- make a multi line name output when someone calls

- apply modifications from here: http://xdaforums.com/showthread.php?t=2091959

All other stuff I'd like to keep stock.

I try to modify SecPhone.apk, the problem is that when I compile .apk file back ApkTool gives errors:

C:\Android\apktool>apktool if framework\framework-res.apk
I: Framework installed to: C:\Users\Sergey\apktool\framework\1.apk

C:\Android\apktool>apktool if framework\twframework-res.apk
I: Framework installed to: C:\Users\Sergey\apktool\framework\2.apk

C:\Android\apktool>apktool d input\SecPhone.apk output
I: Loading resource table...
W: Skipping "android" package group
I: Loaded.
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\Sergey\apktool\framework\1.apk
I: Loaded.
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Done.
I: Copying assets and libs...

C:\Android\apktool>apktool b output SecPhone_new.apk
W: Could not find sources
I: Checking whether resources has changed...
I: Building resources...
aapt: warning: string 'callFailed_timeout_408_487' has no default translation in
C:\Android\apktool\output\res; found: pt
aapt: warning: string 'reject_cause_location_reg_fail' has no default translatio
n in C:\Android\apktool\output\res; found: pt
aapt: warning: string 'reject_cause_location_registering' has no default transla
tion in C:\Android\apktool\output\res; found: pt
aapt: warning: string 'reject_cause_skt_registering' has no default translation
in C:\Android\apktool\output\res; found: pt
C:\Android\apktool\output\res\values-es\strings.xml:195: error: Multiple substit
utions specified in non-positional format; did you mean to add the formatted="fa
lse" attribute?
C:\Android\apktool\output\res\values-es\strings.xml:196: error: Unexpected end t
ag string
C:\Android\apktool\output\res\values-es-rUS\strings.xml:201: error: Multiple sub
stitutions specified in non-positional format; did you mean to add the formatted
="false" attribute?
C:\Android\apktool\output\res\values-es-rUS\strings.xml:202: error: Unexpected e
nd tag string
C:\Android\apktool\output\res\values-it\strings.xml:201: error: Multiple substit
utions specified in non-positional format; did you mean to add the formatted="fa
lse" attribute?
C:\Android\apktool\output\res\values-it\strings.xml:202: error: Unexpected end t
ag string
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.Androl
ibException: brut.common.BrutException: could not exec command: [aapt, p, --min-
sdk-version, 16, --target-sdk-version, 16, -F, C:\Users\Sergey\AppData\Local\Tem
p\APKTOOL548576398050714353.tmp, -0, arsc, -I, C:\Users\Sergey\apktool\framework
\1.apk, -S, C:\Android\apktool\output\res, -M, C:\Android\apktool\output\Android
Manifest.xml]
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:358)
at brut.androlib.Androlib.buildResources(Androlib.java:283)
at brut.androlib.Androlib.build(Androlib.java:206)
at brut.androlib.Androlib.build(Androlib.java:176)
at brut.apktool.Main.cmdBuild(Main.java:228)
at brut.apktool.Main.main(Main.java:79)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not
exec command: [aapt, p, --min-sdk-version, 16, --target-sdk-version, 16, -F, C:
\Users\Sergey\AppData\Local\Temp\APKTOOL548576398050714353.tmp, -0, arsc, -I, C:
\Users\Sergey\apktool\framework\1.apk, -S, C:\Android\apktool\output\res, -M, C:
\Android\apktool\output\AndroidManifest.xml]
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav
a:357)
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:336)
... 5 more
Caused by: brut.common.BrutException: could not exec command: [aapt, p, --min-sd
k-version, 16, --target-sdk-version, 16, -F, C:\Users\Sergey\AppData\Local\Temp\
APKTOOL548576398050714353.tmp, -0, arsc, -I, C:\Users\Sergey\apktool\framework\1
.apk, -S, C:\Android\apktool\output\res, -M, C:\Android\apktool\output\AndroidMa
nifest.xml]
at brut.util.OS.exec(OS.java:89)
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav
a:355)
... 6 more

Used files:

1. twframework-res.apk and framework-res.apk for framework installation

2. SecPhone.apk

3. SecPhone.odex

All these files are from my device.

As far as I know to complete my task I need:

1. Deodex .apk file (none of the automation utilities I tried said that I need deodex .apk file first and then decompile it)

2. Decompile .apk file

3. Modify .xml files I want

4. Compile the modified directory back to new.apk file

5. Sign the .apk file (I dont understand when I need to sign and when not. It seems that instead of signing I can take modified folders from new.apk and put it to old .apk file which is allready signed) and get "modified.apk"

6. Odex "modified.apk" file (I don't understand if I can simply delete old .odex file from the device and it'll create a new on by itself on next reboot?)

7. Put modified.apk and modified.odex files to device back with the root explorer.

Question#1: are these actions right? If no, then tell me please what is right.

I've installed for correct work of ApkTool:

1. Apktool (added files from two directories to Windows folder)

2. Installed latest Java

3. Installed latest JDK

4. All the programms are put to c:\android to remove problems with spaces in paths

What I've tryed to do:

1. Read a lot of similar manuals all over the internet about .apk modifications. The coolest manual is this one.

Unfortunately ApkTool gives errors (see above)

2. With the hope that different utilities will help me to solve the problem I tried:

- APK-Multi-Tool-Stable-RELEASE

- AutoAPKTool2.0.4a

- extend_unpacker_vers3

- SmartAPKTool

- xdaAutoTool_V4.0.3

The result is the same ApkTool error.

The AutoAPKTool2.0.4a uses wrong slashes in path:

[*] framework-res folder

recompiling framework-res.apk...

W: Could not find sources

I: Building resources...

invalid resource directory name: C:\Android\AutoAPKTool2.0.4\_INPUT_APK\framework-res\res/anim-sw720dp

invalid resource directory name: C:\Android\AutoAPKTool2.0.4\_INPUT_APK\framework-res\res/animator

I've found a lot of questions with the same error, but they are all without answers.

Question#2: how to solve the problem with this ApkTool error?

Thank you.