4

Is is possible to create a new APK by overloading/overriding and existing APK.

Say, we have WhatsApp messenger. Now if I want to show a notification like, "Person X is online now.", in notification area, it is not possible using the existing WhatsApp messenger. So, I'd like to develop a new custom messenger, which uses all the functionality of WhatsApp messenger, with some of my custom code. Just like importing JARs, can we import APK...??

This seems like using another persons work, but just from learning point of view, I'd like to know the possibilities. As of now, lets leave all the, security, vulnerability.

Gokul Nath KP
  • 15,485
  • 24
  • 88
  • 126
  • you can reverse engineer apk and add your code and build again – Iftikar Urrhman Khan Jun 24 '13 at 07:07
  • Reverse engineering an APK is not that easy. I tried the steps mentioned here, http://stackoverflow.com/questions/13854425/how-to-avoid-reverse-engineering-of-an-apk-file, but the project is not built successfully. – Gokul Nath KP Jun 24 '13 at 07:10
  • Also this, http://stackoverflow.com/questions/3593420/android-getting-source-code-from-an-apk-file?lq=1. But project is not built successfully. – Gokul Nath KP Jun 24 '13 at 07:11

3 Answers3

6

In a nutshell, no.

APKs are not like Jar files such that you can simply import them into your app. They also contain other resources like the XML and assets. The code is kept in a classes.dex file, which is generated from the Jar file of the app code.

Moreover, each app runs in its own DVM, and is sandboxed to prevent this kind of interaction between apps. You cannot simply use WhatsApp's code in your own app as a third party apps.

There are however two ways to achieve what you want.

  1. If the app you are targeting provides an API by means of content providers, or even web services that you can use to access their data and events like users coming online. WhatsApp does not offer any such API
  2. You decompile the target app, and insert your own code to do what you want. This can be very hard because most popular apps, like WhatsApp, obfuscate their code making it hard to decipher (but not impossible). Additionally, WhatsApp encrypts most of its data like messages, contacts, chat threads etc using AES, which adds an additional layer to bypass in some places. Oh, and it also violates several IP and copyright laws if you do this.
Raghav Sood
  • 81,899
  • 22
  • 187
  • 195
2

Yes and No.

There are a couple of ways for an app - a standalone one - to share its information with other apps. One is through the use of a content provider, the other through custom broadcasts.

If, say, WhatsApp has documented its app and was built such that you can build on it further, you can catch those broadcasts and listen to those providers such that your app can also react upon the changes made in WhatsApp.

josephus
  • 8,284
  • 1
  • 37
  • 57
0

you can create a config.properties file and insert it in Asset folder in your wattsup messenger assuming you have the source code,

Now you will have to configure your custom application to write that changes in this file, however you can change these data in several ways such as webservices that allows you to modify that data in that file through them .

ok with the above scenario, you can make the changes,but your application will never update that changes coz your dealing with an APK not a code,therefore you will have to re-generate the APK again so it will take the latest changes .

for an automated APK generating you can use ANT tools, by placing a build.xml file in your wattsp sources code you can run that script which ant release that will generate the new APK with the latest code as you said these are possibilities still but in my opinion in the end you cant use the APK as a library

mmoghrabi
  • 1,233
  • 1
  • 14
  • 23