I know this is possible to decompile and recompile an apk. And I saw this post : Injecting code into APK before, But what I want is not decompiling or reverse engineering.
In my case I just want to make some games that uses touch events compatible with gamepad. I've seen some companies that do something like this and make android games compatible with their gamepads. Unfortunately I found no solution to inject some codes into an existing apk.
So My question is :
Is there a way to do some changes into an apk (changing touch and key events in game application) and add some codes into that without effecting the real source code ?
For something simple like this, all you need is baksmali/smali. Just insert a single call into the assembly into your custom class, and you can write the rest in Java.
Decompiling/recompiling rarely works and is overkill for this situation anyway. Using smali will work even for obfuscated applications, though some applications calculate integrity checks on themselves and will refuse to run if modified.